简体   繁体   中英

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

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'

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'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM