0

我需要创建一个简单的脚本来修复存储库的 python 脚本中的缩进。我fix_multiple_files在 autopep8 模块中找到:

import autopep8

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

每次我运行脚本时都会得到这个:

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'
4

1 回答 1

0

它是多么正确地注意到约翰夏普argparse.Namespace。获得它的最佳方法是:

opt = autopep8.parse_args(arguments=['recursive', '--in-place', '--aggressive'])
于 2018-11-01T14:57:49.053 回答