Format BoolOp (#4986)

This commit is contained in:
Micha Reiser 2023-06-21 11:27:57 +02:00 committed by GitHub
parent db301c14bd
commit 653dbb6d17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 804 additions and 446 deletions

View file

@ -227,7 +227,7 @@ instruction()#comment with bad spacing
]
not_shareables = [
@@ -37,50 +33,51 @@
@@ -37,49 +33,57 @@
# builtin types and objects
type,
object,
@ -267,13 +267,13 @@ instruction()#comment with bad spacing
- children[0],
+ parameters.NOT_IMPLEMENTED_attr = [
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key], # (1
+ body,
body,
- children[-1], # type: ignore
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key], # )1
+ ]
+ parameters.NOT_IMPLEMENTED_attr = [
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key],
body,
- children[-1], # type: ignore
+ body,
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key], # type: ignore
]
else:
@ -286,24 +286,25 @@ instruction()#comment with bad spacing
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key], # )2
]
- parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]] # type: ignore
- if (
- self._proc is not None
- # has the child process finished?
- and self._returncode is None
- # the child process has finished, but the
- # transport hasn't been notified yet?
- and self._proc.poll() is None
- ):
+ parameters.NOT_IMPLEMENTED_attr = [
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key],
+ body,
+ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key],
+ ] # type: ignore
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
- self._proc is not None
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
# has the child process finished?
- and self._returncode is None
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
# the child process has finished, but the
# transport hasn't been notified yet?
- and self._proc.poll() is None
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
pass
# no newline before or after
short = [
@@ -91,48 +88,14 @@
@@ -91,48 +95,14 @@
]
# no newline after
@ -357,7 +358,7 @@ instruction()#comment with bad spacing
while True:
if False:
continue
@@ -141,25 +104,13 @@
@@ -141,25 +111,13 @@
# and round and round we go
# let's return
@ -386,7 +387,7 @@ instruction()#comment with bad spacing
#######################
@@ -167,7 +118,7 @@
@@ -167,7 +125,7 @@
#######################
@ -479,7 +480,14 @@ def inline_comments_in_brackets_ruin_everything():
body,
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key],
] # type: ignore
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
# has the child process finished?
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
# the child process has finished, but the
# transport hasn't been notified yet?
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
pass
# no newline before or after
short = [

View file

@ -137,7 +137,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
def f(
@@ -49,10 +49,8 @@
@@ -49,10 +49,11 @@
element = 0 # type: int
another_element = 1 # type: float
another_element_with_long_name = 2 # type: int
@ -146,11 +146,14 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
- ) # type: int
- an_element_with_a_long_value = calls() or more_calls() and more() # type: bool
+ another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style = 3 # type: int
+ an_element_with_a_long_value = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2 # type: bool
+ an_element_with_a_long_value = (
+ NOT_IMPLEMENTED_call()
+ or NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
+ ) # type: bool
tup = (
another_element,
@@ -84,35 +82,22 @@
@@ -84,35 +85,22 @@
def func(
@ -255,7 +258,10 @@ def f(
another_element = 1 # type: float
another_element_with_long_name = 2 # type: int
another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style = 3 # type: int
an_element_with_a_long_value = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2 # type: bool
an_element_with_a_long_value = (
NOT_IMPLEMENTED_call()
or NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
) # type: bool
tup = (
another_element,

View file

@ -105,7 +105,7 @@ def g():
```diff
--- Black
+++ Ruff
@@ -1,47 +1,35 @@
@@ -1,89 +1,79 @@
-"""Docstring."""
+"NOT_YET_IMPLEMENTED_STRING"
@ -142,7 +142,7 @@ def g():
- prevp = preceding_leaf(p)
- if not prevp or prevp.type in OPENING_BRACKETS:
+ prevp = NOT_IMPLEMENTED_call()
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
return NO
- if prevp.type == token.EQUAL:
@ -154,7 +154,10 @@ def g():
- syms.argument,
- }:
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ if (
+ prevp.NOT_IMPLEMENTED_attr
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ ):
return NO
- elif prevp.type == token.DOUBLESTAR:
@ -166,15 +169,18 @@ def g():
- syms.dictsetmaker,
- }:
+ elif NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ if (
+ prevp.NOT_IMPLEMENTED_attr
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ ):
return NO
@@ -49,41 +37,34 @@
###############################################################################
# SECTION BECAUSE SECTIONS
###############################################################################
-
def g():
- NO = ""
- SPACE = " "
@ -210,7 +216,7 @@ def g():
+ prevp = NOT_IMPLEMENTED_call()
- if not prevp or prevp.type in OPENING_BRACKETS:
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
# Start of the line or a bracketed expression.
# More than one line for the comment.
return NO
@ -224,7 +230,10 @@ def g():
- syms.argument,
- }:
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
+ if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ if (
+ prevp.NOT_IMPLEMENTED_attr
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ ):
return NO
```
@ -254,15 +263,21 @@ def f():
prev = leaf.NOT_IMPLEMENTED_attr
if not prev:
prevp = NOT_IMPLEMENTED_call()
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
return NO
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
prevp.NOT_IMPLEMENTED_attr
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
return NO
elif NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
prevp.NOT_IMPLEMENTED_attr
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
return NO
@ -293,13 +308,16 @@ def g():
if not prev:
prevp = NOT_IMPLEMENTED_call()
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
# Start of the line or a bracketed expression.
# More than one line for the comment.
return NO
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
prevp.NOT_IMPLEMENTED_attr
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
return NO
```

View file

@ -276,43 +276,10 @@ last_call()
Name
None
True
@@ -7,18 +8,18 @@
1
1.0
1j
-True or False
-True or False or None
-True and False
-True and False and None
-(Name1 and Name2) or Name3
-Name1 and Name2 or Name3
-Name1 or (Name2 and Name3)
-Name1 or Name2 and Name3
-(Name1 and Name2) or (Name3 and Name4)
-Name1 and Name2 or Name3 and Name4
-Name1 or (Name2 and Name3) or Name4
-Name1 or Name2 and Name3 or Name4
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
v1 << 2
1 >> v2
1 % finished
@@ -28,205 +29,204 @@
~great
+value
@@ -30,203 +31,178 @@
-1
-~int and not v1 ^ 123 + v2 | True
-(~int) and (not ((v1 ^ (123 + v2)) | True))
~int and not v1 ^ 123 + v2 | True
(~int) and (not ((v1 ^ (123 + v2)) | True))
-+(really ** -(confusing ** ~(operator**-precedence)))
-flags & ~select.EPOLLIN and waiters.write_task is not None
-lambda arg: None
@ -337,10 +304,8 @@ last_call()
-)
-{"2.7": dead, "3.7": (long_live or die_hard)}
-{"2.7": dead, "3.7": (long_live or die_hard), **{"3.6": verygood}}
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
++really ** -confusing ** ~operator**-precedence
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+flags & ~select.NOT_IMPLEMENTED_attr and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+lambda x: True
+lambda x: True
+lambda x: True
@ -356,15 +321,11 @@ last_call()
+(NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false)
+{
+ "NOT_YET_IMPLEMENTED_STRING": dead,
+ "NOT_YET_IMPLEMENTED_STRING": (
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+ ),
+ "NOT_YET_IMPLEMENTED_STRING": (long_live or die_hard),
+}
+{
+ "NOT_YET_IMPLEMENTED_STRING": dead,
+ "NOT_YET_IMPLEMENTED_STRING": (
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+ ),
+ "NOT_YET_IMPLEMENTED_STRING": (long_live or die_hard),
+ **{"NOT_YET_IMPLEMENTED_STRING": verygood},
+}
{**a, **b, **c}
@ -378,32 +339,31 @@ last_call()
+ "NOT_YET_IMPLEMENTED_STRING",
+ (NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false),
+}
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+(
+ {"NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING"},
+ (True or False),
+ (+value),
+ "NOT_YET_IMPLEMENTED_STRING",
+ b"NOT_YET_IMPLEMENTED_BYTE_STRING",
+) or None
()
(1,)
(1, 2)
(1, 2, 3)
[]
-[1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
[
1,
2,
3,
[1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
-[
- 1,
- 2,
- 3,
-]
-[*a]
-[*range(10)]
-[
- *a,
4,
5,
+ 6,
+ 7,
+ 8,
+ 9,
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
]
- 4,
- 5,
-]
-[
- 4,
- *a,
@ -503,7 +463,7 @@ last_call()
- k: v
- for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ "NOT_YET_IMPLEMENTED_STRING": dead,
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
+ "NOT_YET_IMPLEMENTED_STRING": long_live or die_hard,
}
-Python3 > Python2 > COBOL
-Life is Life
@ -540,28 +500,7 @@ last_call()
-]
-very_long_variable_name_filters: t.List[
- t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
+{
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false,
+}
+[
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
]
-]
-xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod( # type: ignore
- sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
-)
@ -600,7 +539,15 @@ last_call()
-(str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
-{"2.7": dead, "3.7": long_live or die_hard}
-{"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
-[1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
+{
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ "NOT_YET_IMPLEMENTED_STRING",
+ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false,
+}
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
(SomeName)
SomeName
(Good, Bad, Ugly)
@ -638,19 +585,10 @@ last_call()
-g = 1, *"ten"
-what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
- vars_to_remove
+e = NOT_IMPLEMENTED_call()
+f = 1, NOT_YET_IMPLEMENTED_ExprStarred
+g = 1, NOT_YET_IMPLEMENTED_ExprStarred
+what_is_up_with_those_new_coord_names = (
+ (coord_names + NOT_IMPLEMENTED_call())
+ + NOT_IMPLEMENTED_call()
)
-)
-what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
- vars_to_remove
+what_is_up_with_those_new_coord_names = (
+ (coord_names | NOT_IMPLEMENTED_call())
+ - NOT_IMPLEMENTED_call()
)
-)
-result = (
- session.query(models.Customer.id)
- .filter(
@ -658,7 +596,13 @@ last_call()
- )
- .order_by(models.Customer.id.asc())
- .all()
-)
+e = NOT_IMPLEMENTED_call()
+f = 1, NOT_YET_IMPLEMENTED_ExprStarred
+g = 1, NOT_YET_IMPLEMENTED_ExprStarred
+what_is_up_with_those_new_coord_names = (
+ (coord_names + NOT_IMPLEMENTED_call())
+ + NOT_IMPLEMENTED_call()
)
-result = (
- session.query(models.Customer.id)
- .filter(
@ -668,7 +612,10 @@ last_call()
- models.Customer.id.asc(),
- )
- .all()
-)
+what_is_up_with_those_new_coord_names = (
+ (coord_names | NOT_IMPLEMENTED_call())
+ - NOT_IMPLEMENTED_call()
)
-Ø = set()
-authors.łukasz.say_thanks()
+result = NOT_IMPLEMENTED_call()
@ -678,7 +625,7 @@ last_call()
mapping = {
A: 0.25 * (10.0 / 12),
B: 0.1 * (10.0 / 12),
@@ -236,65 +236,35 @@
@@ -236,64 +212,38 @@
def gen():
@ -715,7 +662,6 @@ last_call()
- ...
-for j in 1 + (2 + 3):
- ...
-while this and that:
+NOT_IMPLEMENTED_call()
+NOT_IMPLEMENTED_call()
+NOT_IMPLEMENTED_call()
@ -727,7 +673,7 @@ last_call()
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
+while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
while this and that:
...
-for (
- addr_family,
@ -753,21 +699,22 @@ last_call()
- aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
- is not qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
-)
-if (
- threading.current_thread() != threading.main_thread()
- and threading.current_thread() != threading.main_thread()
- or signal.getsignal(signal.SIGINT) != signal.default_int_handler
-):
+NOT_YET_IMPLEMENTED_StmtFor
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
- threading.current_thread() != threading.main_thread()
- and threading.current_thread() != threading.main_thread()
- or signal.getsignal(signal.SIGINT) != signal.default_int_handler
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
return True
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -327,24 +297,44 @@
@@ -327,24 +277,44 @@
):
return True
if (
@ -824,7 +771,7 @@ last_call()
):
return True
(
@@ -363,8 +353,9 @@
@@ -363,8 +333,9 @@
bbbb >> bbbb * bbbb
(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -851,18 +798,18 @@ False
1
1.0
1j
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
True or False
True or False or None
True and False
True and False and None
(Name1 and Name2) or Name3
Name1 and Name2 or Name3
Name1 or (Name2 and Name3)
Name1 or Name2 and Name3
(Name1 and Name2) or (Name3 and Name4)
Name1 and Name2 or Name3 and Name4
Name1 or (Name2 and Name3) or Name4
Name1 or Name2 and Name3 or Name4
v1 << 2
1 >> v2
1 % finished
@ -872,10 +819,10 @@ not great
~great
+value
-1
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
~int and not v1 ^ 123 + v2 | True
(~int) and (not ((v1 ^ (123 + v2)) | True))
+really ** -confusing ** ~operator**-precedence
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
flags & ~select.NOT_IMPLEMENTED_attr and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
lambda x: True
lambda x: True
lambda x: True
@ -891,15 +838,11 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
(NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false)
{
"NOT_YET_IMPLEMENTED_STRING": dead,
"NOT_YET_IMPLEMENTED_STRING": (
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
),
"NOT_YET_IMPLEMENTED_STRING": (long_live or die_hard),
}
{
"NOT_YET_IMPLEMENTED_STRING": dead,
"NOT_YET_IMPLEMENTED_STRING": (
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
),
"NOT_YET_IMPLEMENTED_STRING": (long_live or die_hard),
**{"NOT_YET_IMPLEMENTED_STRING": verygood},
}
{**a, **b, **c}
@ -911,26 +854,19 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
"NOT_YET_IMPLEMENTED_STRING",
(NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false),
}
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
(
{"NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING"},
(True or False),
(+value),
"NOT_YET_IMPLEMENTED_STRING",
b"NOT_YET_IMPLEMENTED_BYTE_STRING",
) or None
()
(1,)
(1, 2)
(1, 2, 3)
[]
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
]
[1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
[1, 2, 3]
[NOT_YET_IMPLEMENTED_ExprStarred]
[NOT_YET_IMPLEMENTED_ExprStarred]
@ -1010,7 +946,7 @@ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
{
"NOT_YET_IMPLEMENTED_STRING": dead,
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
"NOT_YET_IMPLEMENTED_STRING": long_live or die_hard,
}
{
"NOT_YET_IMPLEMENTED_STRING",
@ -1020,20 +956,7 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
"NOT_YET_IMPLEMENTED_STRING",
NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false,
}
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
(SomeName)
SomeName
(Good, Bad, Ugly)
@ -1100,14 +1023,18 @@ NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
while this and that:
...
NOT_YET_IMPLEMENTED_StmtFor
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
return True
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View file

@ -22,15 +22,17 @@ else:
```diff
--- Black
+++ Ruff
@@ -1,9 +1,5 @@
@@ -1,9 +1,9 @@
a, b, c = 3, 4, 5
-if (
if (
- a == 3
- and b != 9 # fmt: skip
- and c is not None
-):
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right # fmt: skip
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
- print("I'm good!")
+if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+ NOT_IMPLEMENTED_call()
else:
- print("I'm bad")
@ -41,7 +43,11 @@ else:
```py
a, b, c = 3, 4, 5
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right # fmt: skip
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
NOT_IMPLEMENTED_call()
else:
NOT_IMPLEMENTED_call()

View file

@ -97,7 +97,7 @@ func(
+ b,
+ c,
+ d,
+) = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
-func(argument1, (one, two), argument4, argument5, argument6)
+NOT_IMPLEMENTED_call()
@ -133,7 +133,7 @@ NOT_IMPLEMENTED_call()
b,
c,
d,
) = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
NOT_IMPLEMENTED_call()
```

View file

@ -42,7 +42,7 @@ assert (
```diff
--- Black
+++ Ruff
@@ -2,57 +2,21 @@
@@ -2,57 +2,24 @@
(
()
<< 0
@ -96,8 +96,10 @@ assert (
- othr.parameters,
- othr.meta_data,
- othr.schedule,
- )
+ return NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+ return (
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
)
-assert a_function(
@ -128,7 +130,10 @@ NOT_YET_IMPLEMENTED_StmtClassDef
def test(self, othr):
return NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
return (
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
)
NOT_YET_IMPLEMENTED_StmtAssert

View file

@ -43,7 +43,7 @@ class A:
- _winapi.ERROR_SEM_TIMEOUT,
- _winapi.ERROR_PIPE_BUSY,
-) or _check_timeout(t):
+if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right or NOT_IMPLEMENTED_call():
pass
if x:
@ -82,7 +82,7 @@ class A:
## Ruff Output
```py
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right or NOT_IMPLEMENTED_call():
pass
if x:

View file

@ -16,20 +16,26 @@ if (e123456.get_tk_patchlevel() >= (8, 6, 0, 'final') or
```diff
--- Black
+++ Ruff
@@ -1,6 +1,2 @@
@@ -1,6 +1,5 @@
-if e123456.get_tk_patchlevel() >= (8, 6, 0, "final") or (
- 8,
- 5,
- 8,
-) <= get_tk_patchlevel() < (8, 6):
+if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
+if (
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+ or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+):
pass
```
## Ruff Output
```py
if NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
if (
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
):
pass
```

View file

@ -75,7 +75,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
-) = func1(
- arg1
-) and func2(arg2)
+) = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
+) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
# Example from https://github.com/psf/black/issues/3229
@ -121,7 +121,7 @@ NOT_IMPLEMENTED_call()
b,
c,
d,
) = NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
# Example from https://github.com/psf/black/issues/3229

View file

@ -0,0 +1,143 @@
---
source: crates/ruff_python_formatter/src/lib.rs
expression: snapshot
---
## Input
```py
if (
self._proc
# has the child process finished?
and self._returncode
# the child process has finished, but the
# transport hasn't been notified yet?
and self._proc.poll()
):
pass
if (
self._proc
and self._returncode
and self._proc.poll()
and self._proc
and self._returncode
and self._proc.poll()
):
...
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaaaaaa
):
...
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas
and aaaaaaaaaaaaaaaaa
):
...
if [2222, 333] and [
aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbb,
cccccccccccccccccccc,
dddddddddddddddddddd,
eeeeeeeeee,
]:
...
if [
aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbb,
cccccccccccccccccccc,
dddddddddddddddddddd,
eeeeeeeeee,
] and [2222, 333]:
pass
# Break right only applies for boolean operations with a left and right side
if (
aaaaaaaaaaaaaaaaaaaaaaaaaa
and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
and ccccccccccccccccc
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
):
pass
```
## Output
```py
if (
self.NOT_IMPLEMENTED_attr
# has the child process finished?
and self.NOT_IMPLEMENTED_attr
# the child process has finished, but the
# transport hasn't been notified yet?
and NOT_IMPLEMENTED_call()
):
pass
if (
self.NOT_IMPLEMENTED_attr
and self.NOT_IMPLEMENTED_attr
and NOT_IMPLEMENTED_call()
and self.NOT_IMPLEMENTED_attr
and self.NOT_IMPLEMENTED_attr
and NOT_IMPLEMENTED_call()
):
...
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaaaa
and aaaaaaaaaaaaaaaaaaaaaaaaaaaa
):
...
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas
and aaaaaaaaaaaaaaaaa
):
...
if [2222, 333] and [
aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbb,
cccccccccccccccccccc,
dddddddddddddddddddd,
eeeeeeeeee,
]:
...
if [
aaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbb,
cccccccccccccccccccc,
dddddddddddddddddddd,
eeeeeeeeee,
] and [2222, 333]:
pass
# Break right only applies for boolean operations with a left and right side
if (
aaaaaaaaaaaaaaaaaaaaaaaaaa
and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
and ccccccccccccccccc
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
):
pass
```

View file

@ -61,12 +61,14 @@ while (
else:
...
while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2: # comment
while NOT_IMPLEMENTED_call() and anotherCondition or aThirdCondition: # comment
NOT_IMPLEMENTED_call()
while (
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2 # trailing third condition
NOT_IMPLEMENTED_call() # trailing some condition
and anotherCondition
or aThirdCondition # trailing third condition
): # comment
NOT_IMPLEMENTED_call()
```