Force Yapf to wrap lines after expression/just before for-loop in list comprehension

1k Views Asked by At

yapf formatter can wrap long lines in the code inside parentheses in the expression in the list comprehension:

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

I want to wrap just before the for-loop instead:

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

yapf --help-style doesn't show anything obvious that can help here.

I can add # yapf: disable at the end of the line, to disable yapf. Is there some other way to force different formatting preference?

Current yapf/style settings:

[style]
based_on_style = pep8
column_limit = 89

Version:

>>> import yapf
>>> yapf.__version__
'0.13.2' # the latest on github
0

There are 0 best solutions below