mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:09 +00:00
Fix formatting of chained boolean operations (#6394)
Closes https://github.com/astral-sh/ruff/issues/6068 These commits are kind of a mess as I did some stumbling around here. Unrolls formatting of chained boolean operations to prevent nested grouping which gives us Black-compatible formatting where each boolean operation is on a new line.
This commit is contained in:
parent
63ffadf0b8
commit
999d88e773
5 changed files with 177 additions and 16 deletions
|
@ -180,7 +180,8 @@ def test():
|
|||
", %s unmodified" % unmodified_count if collected["unmodified"] else ""
|
||||
),
|
||||
"post_processed": (
|
||||
collected["post_processed"] and ", %s post-processed" % post_processed_count
|
||||
collected["post_processed"]
|
||||
and ", %s post-processed" % post_processed_count
|
||||
or ""
|
||||
),
|
||||
}
|
||||
|
|
|
@ -68,6 +68,38 @@ if (
|
|||
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
|
||||
):
|
||||
pass
|
||||
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/6068
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) or numpy and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) and numpy or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) or (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy) and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) and (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy) or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -136,6 +168,58 @@ if (
|
|||
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
|
||||
):
|
||||
pass
|
||||
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/6068
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or numpy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and numpy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue