google / google/yapf

-l command line argument (redux)

Open
#746 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

I cannot reopen a bug but it looks #565 is still not solved as of 0.28.0.

I just retested and it's still just as buggy as before:

> I can confirm the issue with yapf 0.21.0:
>
> ```
> % cat -n /tmp/id.py
> 1 a = {1:
> 2 2, 3:4}
> 3
> 4 # hello
> 5
> 6
> % yapf -d -l 1-2 /tmp/id.py
> --- /tmp/id.py (original)
> +++ /tmp/id.py (reformatted)
> @@ -1,6 +1,3 @@
> -a = {1:
> -2, 3:4}
> +a = {1: 2, 3: 4}
>
> # hello
> -
> -
> ```
>
> yapf is told to reformat only lines 1 to 2 but it removes blank lines 5 and 6 which are clearly out of the specified range.
>
> The `-l` argument handling seems very buggy, please fix it.

The lines 1-2 are not selected and so should not be reformatted, but yapf insists on doing it

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.