I am Using yapf 0.40.1
with Python 3.10.4
.
I have a pyproject.toml
file with the following config:
[tool.yapf]
based_on_style='yapf'
column_limit=120
spaces_before_comment=2
continuation_indent_width=2
indent_width=2
coalesce_brackets=true
dedent_closing_brackets=true
When running yapf ( yapf -ir --style pyproject.toml yapf_test.py
), the following code is not formatted (yapf_test.py
only contains these lines):
def x( # x
xxxx,
xxxxxxxxxxxxx: type_annotation, xxxxxxxxxx: type_annotation, xxxxxxxxxx: type_annotation
) -> type_annotation:
pass
when I remove the comment i.e. the # x
in the first line, it is formatted to
def x(
xxxx, xxxxxxxxxxxxx: type_annotation, xxxxxxxxxx: type_annotation, xxxxxxxxxx: type_annotation
) -> type_annotation:
pass
It seems that the presence of this comment somehow disables yapf. What can I do that it is formatted even if the comment is present? What causes this behavior?
Note that I cannot just get rid of the comment, since this naturally occurs when e.g. silencing mypy
errors, which have to be on the same line where they occur.