强制Yapf在表达式之后/在列表推导中的for循环之前包装行

jfs*_*jfs 8 python code-formatting yapf

yapfformatter可以在列表解析中的表达式中的括号内的代码中包含长行:

threads = [threading.Thread(
    target=worker, args=[q], daemon=True) for _ in range(worker_count)]
Run Code Online (Sandbox Code Playgroud)

我想for-loop 之前换行:

threads = [threading.Thread(target=worker, args=[q], daemon=True)
           for _ in range(worker_count)]
Run Code Online (Sandbox Code Playgroud)

yapf --help-style 没有任何显而易见的东西可以帮到这里.

我可以# yapf: disable在该行的末尾添加,以禁用yapf.有没有其他方法来强制不同的格式偏好?

当前yapf/style设置:

[style]
based_on_style = pep8
column_limit = 89
Run Code Online (Sandbox Code Playgroud)

版:

>>> import yapf
>>> yapf.__version__
'0.13.2' # the latest on github
Run Code Online (Sandbox Code Playgroud)