Parser fails due to empty body ...
on same line as definition. Discrepancy in whole file and --line-ranges
parsing
#4669
Labels
T: bug
Something isn't working
Describe the bug
Originally I realized that in VSCode the black formatter does not format my code anymore, i.e. the
--line-ranges
is broken and raises a parser error.Observation: Difference between
black file.py
andblack --line-range #-# file.py
If there is a
def foo(self): ...
with...
on the same lineblack
fails to format anything after when used with--line-range
.To Reproduce
For example, take this code:
And run it with these arguments:
Fails:
Formatting only the
...
line changes nothingWorks:
--line-ranges
works correctly and does change the long line; also including the seemingly "broken" line seems to work fine....
on the next line and then format it is fine:In the end, if I format everything
...
is again put on the same line and--line-ranges
breaks for further editing.Expected behavior
Parser should not be bothered if
...
is on the same line or below anywhere, to have--line-ranges
work everywhere independent of style used in above code.Environment
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: