使用以下autopep8
命令:
autopep8 --pep8-passes 2000 --verbose --aggressive --aggressive --ignore=E501,E722
和python代码片段:
parser.add_argument('-a', '--auto', help='Activate automatic semi-intelligent inference for --some-long-flags and --other-long-flags. '
'--some-long-flags will be activated when the primary manifold script is presented with a single-node cluster. '
'--other-long-flags will be enabled when no resources are specified in the helm overrides file.', action='store_true')
最终结果是:
parser.add_argument('-a', '--auto', help='Activate automatic semi-intelligent inference for --some-long-flags and --other-long-flags. '
'--some-long-flags will be activated when the primary manifold script is presented with a single-node cluster. '
'--other-long-flags will be enabled when no resources are specified in the helm overrides file.', action='store_true')
注意--auto
标志的多行缩进现在如何与parser.add_argument(
块的末尾对齐,而不是缩进比父级更深的1级。
我明白这是pep8 advises as the recommended way。同时,就个人而言,我鄙视这种格式化风格,并找到它:
根据函数字符串名称的长度不一致和任意。
在不使用具有此风格意识的IDE或编辑器时手动输入非常烦人。
我不确定这种代码格式的正确名称,IntelliJ似乎将其称为“Continuation indent”。有没有办法轻轻地引导autopep8远离强迫这种风格?
另请参阅the full runnable example code inputs and outputs,其中包含pretty diff view次编辑,autopep8希望申请。