What kind of object do I need to use the options parameter of fix_multiple_files?

84 views Asked by At

I need to create a simple script for fixing indentation in python scripts of the repository. I found fix_multiple_files in autopep8 module:

import autopep8

autopep8.fix_multiple_files('/home/playrix/work/ci-teamcity/scripts/', options={'recursive': 1})

I'm getting this every time I run the script:

Traceback (most recent call last):
  File "/home/playrix/work/ci-teamcity/scripts/1.py", line 4, in <module>
    autopep8.fix_multiple_files('/home/playrix/work/ci-teamcity/scripts/', options='')
  File "/home/playrix/.local/lib/python2.7/site-packages/autopep8.py", line 3897, in fix_multiple_files
    filenames = find_files(filenames, options.recursive, options.exclude)
AttributeError: 'str' object has no attribute 'recursive'
1

There are 1 answers

0
Евгений Боченков On

How correctly noticed johnsharpe it was argparse.Namespace. And the best way to get it was:

opt = autopep8.parse_args(arguments=['recursive', '--in-place', '--aggressive'])