Summary
In our code base we have a specific piece of code which is legit but seems to throw off ruff format.
It gives the error message: error: Failed to format [path/to/file.py]: Invalid document: Expected end tag of kind Group but found Indent.
I reproduced it with this snippet, which can also be found on the playground
class CantFormat:
args: list[int]
def __str__(self) -> str:
return (
"first string"
f"list of args long={list(map(lambda arg: str(arg), self.args))})"
)
ruff format does not fail when the two lines are short enough to be formatted into a single line.
Version
ruff 0.15.14 (9ad2da3 2026-05-21)
Summary
In our code base we have a specific piece of code which is legit but seems to throw off
ruff format.It gives the error message:
error: Failed to format [path/to/file.py]: Invalid document: Expected end tag of kind Group but found Indent.I reproduced it with this snippet, which can also be found on the playground
ruff formatdoes not fail when the two lines are short enough to be formatted into a single line.Version
ruff 0.15.14 (9ad2da3 2026-05-21)