Change generator formatting dummy to include NOT_YET_IMPLEMENTED (#5464)

## Summary

Change generator formatting dummy to include `NOT_YET_IMPLEMENTED`. This
makes it easier to correctly identify them as dummies

## Test Plan

This is a dummy change
This commit is contained in:
konsti 2023-07-03 09:11:14 +02:00 committed by GitHub
parent 94ac2c4e1b
commit ca6ff72404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 138 additions and 90 deletions

View file

@ -11,7 +11,12 @@ pub struct FormatExprGeneratorExp;
impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp { impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
fn fmt_fields(&self, _item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> { fn fmt_fields(&self, _item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [not_yet_implemented_custom_text("(i for i in [])")]) write!(
f,
[not_yet_implemented_custom_text(
"(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])"
)]
)
} }
} }

View file

@ -11,7 +11,12 @@ pub struct FormatExprListComp;
impl FormatNodeRule<ExprListComp> for FormatExprListComp { impl FormatNodeRule<ExprListComp> for FormatExprListComp {
fn fmt_fields(&self, _item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> { fn fmt_fields(&self, _item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [not_yet_implemented_custom_text("[i for i in []]")]) write!(
f,
[not_yet_implemented_custom_text(
"[NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]"
)]
)
} }
} }

View file

@ -79,7 +79,7 @@ def something():
```diff ```diff
--- Black --- Black
+++ Ruff +++ Ruff
@@ -1,90 +1,48 @@ @@ -1,90 +1,50 @@
long_kwargs_single_line = my_function( long_kwargs_single_line = my_function(
foo="test, this is a sample value", foo="test, this is a sample value",
- bar=( - bar=(
@ -157,21 +157,21 @@ def something():
- ) - )
- for some_boolean_variable in some_iterable - for some_boolean_variable in some_iterable
-) -)
+generator_expression = (i for i in []) +generator_expression = (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def limit_offset_sql(self, low_mark, high_mark): def limit_offset_sql(self, low_mark, high_mark):
"""Return LIMIT/OFFSET SQL clause.""" """Return LIMIT/OFFSET SQL clause."""
limit, offset = self._get_limit_offset_params(low_mark, high_mark) limit, offset = self._get_limit_offset_params(low_mark, high_mark)
- return " ".join( return " ".join(
- sql - sql
- for sql in ( - for sql in (
- "LIMIT %d" % limit if limit else None, - "LIMIT %d" % limit if limit else None,
- ("OFFSET %d" % offset) if offset else None, - ("OFFSET %d" % offset) if offset else None,
- ) - )
- if sql - if sql
- ) + (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+ return " ".join((i for i in [])) )
def something(): def something():
@ -221,13 +221,15 @@ def weird_default_argument(
nested = NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false nested = NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
generator_expression = (i for i in []) generator_expression = (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def limit_offset_sql(self, low_mark, high_mark): def limit_offset_sql(self, low_mark, high_mark):
"""Return LIMIT/OFFSET SQL clause.""" """Return LIMIT/OFFSET SQL clause."""
limit, offset = self._get_limit_offset_params(low_mark, high_mark) limit, offset = self._get_limit_offset_params(low_mark, high_mark)
return " ".join((i for i in [])) return " ".join(
(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
)
def something(): def something():

View file

@ -134,7 +134,7 @@ with match() as match:
def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]: def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
@@ -23,13 +23,9 @@ @@ -23,13 +23,11 @@
pygram.python_grammar, pygram.python_grammar,
] ]
@ -146,11 +146,13 @@ with match() as match:
+ NOT_YET_IMPLEMENTED_StmtMatch + NOT_YET_IMPLEMENTED_StmtMatch
- if all(version.is_python2() for version in target_versions): - if all(version.is_python2() for version in target_versions):
+ if all((i for i in [])): + if all(
+ (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+ ):
# Python 2-only code, so try Python 2 grammars. # Python 2-only code, so try Python 2 grammars.
return [ return [
# Python 2.7 with future print_function import # Python 2.7 with future print_function import
@@ -41,13 +37,11 @@ @@ -41,13 +39,11 @@
re.match() re.match()
match = a match = a
with match() as match: with match() as match:
@ -166,7 +168,7 @@ with match() as match:
self.assertIs(x, False) self.assertIs(x, False)
self.assertEqual(y, 0) self.assertEqual(y, 0)
self.assertIs(z, x) self.assertIs(z, x)
@@ -72,16 +66,12 @@ @@ -72,16 +68,12 @@
def test_patma_155(self): def test_patma_155(self):
x = 0 x = 0
y = None y = None
@ -185,7 +187,7 @@ with match() as match:
# At least one of the above branches must have been taken, because every Python # At least one of the above branches must have been taken, because every Python
# version has exactly one of the two 'ASYNC_*' flags # version has exactly one of the two 'ASYNC_*' flags
@@ -91,7 +81,7 @@ @@ -91,7 +83,7 @@
def lib2to3_parse(src_txt: str, target_versions: Iterable[TargetVersion] = ()) -> Node: def lib2to3_parse(src_txt: str, target_versions: Iterable[TargetVersion] = ()) -> Node:
"""Given a string with source, return the lib2to3 Node.""" """Given a string with source, return the lib2to3 Node."""
if not src_txt.endswith("\n"): if not src_txt.endswith("\n"):
@ -194,7 +196,7 @@ with match() as match:
grammars = get_grammars(set(target_versions)) grammars = get_grammars(set(target_versions))
@@ -99,9 +89,9 @@ @@ -99,9 +91,9 @@
re.match() re.match()
match = a match = a
with match() as match: with match() as match:
@ -238,7 +240,9 @@ def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
NOT_YET_IMPLEMENTED_StmtMatch NOT_YET_IMPLEMENTED_StmtMatch
if all((i for i in [])): if all(
(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
):
# Python 2-only code, so try Python 2 grammars. # Python 2-only code, so try Python 2 grammars.
return [ return [
# Python 2.7 with future print_function import # Python 2.7 with future print_function import

View file

@ -27,7 +27,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
```diff ```diff
--- Black --- Black
+++ Ruff +++ Ruff
@@ -1,15 +1,15 @@ @@ -1,15 +1,20 @@
# Unparenthesized walruses are now allowed in indices since Python 3.10. # Unparenthesized walruses are now allowed in indices since Python 3.10.
-x[a:=0] -x[a:=0]
-x[a:=0, b:=1] -x[a:=0, b:=1]
@ -38,7 +38,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
# Walruses are allowed inside generator expressions on function calls since 3.10. # Walruses are allowed inside generator expressions on function calls since 3.10.
-if any(match := pattern_error.match(s) for s in buffer): -if any(match := pattern_error.match(s) for s in buffer):
+if any((i for i in [])): +if any((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])):
if match.group(2) == data_not_available: if match.group(2) == data_not_available:
# Error OK to ignore. # Error OK to ignore.
pass pass
@ -47,10 +47,15 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
-f((a := b + c for c in range(10)), x) -f((a := b + c for c in range(10)), x)
-f(y=(a := b + c for c in range(10))) -f(y=(a := b + c for c in range(10)))
-f(x, (a := b + c for c in range(10)), y=z, **q) -f(x, (a := b + c for c in range(10)), y=z, **q)
+f((i for i in [])) +f((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []))
+f((i for i in []), x) +f((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []), x)
+f(y=(i for i in [])) +f(y=(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []))
+f(x, (i for i in []), y=z, **q) +f(
+ x,
+ (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []),
+ y=z,
+ **q,
+)
``` ```
## Ruff Output ## Ruff Output
@ -62,15 +67,20 @@ x[NOT_YET_IMPLEMENTED_ExprNamedExpr, NOT_YET_IMPLEMENTED_ExprNamedExpr]
x[5, NOT_YET_IMPLEMENTED_ExprNamedExpr] x[5, NOT_YET_IMPLEMENTED_ExprNamedExpr]
# Walruses are allowed inside generator expressions on function calls since 3.10. # Walruses are allowed inside generator expressions on function calls since 3.10.
if any((i for i in [])): if any((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])):
if match.group(2) == data_not_available: if match.group(2) == data_not_available:
# Error OK to ignore. # Error OK to ignore.
pass pass
f((i for i in [])) f((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []))
f((i for i in []), x) f((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []), x)
f(y=(i for i in [])) f(y=(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []))
f(x, (i for i in []), y=z, **q) f(
x,
(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []),
y=z,
**q,
)
``` ```
## Black Output ## Black Output

View file

@ -47,7 +47,7 @@ def make_arange(n):
def f(): def f():
- return (i * 2 async for i in arange(42)) - return (i * 2 async for i in arange(42))
+ return (i for i in []) + return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def g(): def g():
@ -55,7 +55,7 @@ def make_arange(n):
- something_long * something_long - something_long * something_long
- async for something_long in async_generator(with_an_argument) - async for something_long in async_generator(with_an_argument)
- ) - )
+ return (i for i in []) + return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
async def func(): async def func():
@ -66,17 +66,17 @@ def make_arange(n):
- self.async_inc, arange(8), batch_size=3 - self.async_inc, arange(8), batch_size=3
- ) - )
- ] - ]
+ out_batched = [i for i in []] + out_batched = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
def awaited_generator_value(n): def awaited_generator_value(n):
- return (await awaitable for awaitable in awaitable_list) - return (await awaitable for awaitable in awaitable_list)
+ return (i for i in []) + return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def make_arange(n): def make_arange(n):
- return (i * 2 for i in range(n) if await wrap(i)) - return (i * 2 for i in range(n) if await wrap(i))
+ return (i for i in []) + return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
``` ```
## Ruff Output ## Ruff Output
@ -86,24 +86,24 @@ def make_arange(n):
def f(): def f():
return (i for i in []) return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def g(): def g():
return (i for i in []) return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
async def func(): async def func():
if test: if test:
out_batched = [i for i in []] out_batched = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
def awaited_generator_value(n): def awaited_generator_value(n):
return (i for i in []) return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
def make_arange(n): def make_arange(n):
return (i for i in []) return (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
``` ```
## Black Output ## Black Output

View file

@ -76,7 +76,7 @@ while x := f(x):
-y0 = (y1 := f(x)) -y0 = (y1 := f(x))
-foo(x=(y := f(x))) -foo(x=(y := f(x)))
+[NOT_YET_IMPLEMENTED_ExprNamedExpr, y**2, y**3] +[NOT_YET_IMPLEMENTED_ExprNamedExpr, y**2, y**3]
+filtered_data = [i for i in []] +filtered_data = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+(NOT_YET_IMPLEMENTED_ExprNamedExpr) +(NOT_YET_IMPLEMENTED_ExprNamedExpr)
+y0 = NOT_YET_IMPLEMENTED_ExprNamedExpr +y0 = NOT_YET_IMPLEMENTED_ExprNamedExpr
+foo(x=(NOT_YET_IMPLEMENTED_ExprNamedExpr)) +foo(x=(NOT_YET_IMPLEMENTED_ExprNamedExpr))
@ -117,7 +117,7 @@ while x := f(x):
+len(NOT_YET_IMPLEMENTED_ExprNamedExpr) +len(NOT_YET_IMPLEMENTED_ExprNamedExpr)
+foo(NOT_YET_IMPLEMENTED_ExprNamedExpr, cat="vector") +foo(NOT_YET_IMPLEMENTED_ExprNamedExpr, cat="vector")
+foo(cat=(NOT_YET_IMPLEMENTED_ExprNamedExpr)) +foo(cat=(NOT_YET_IMPLEMENTED_ExprNamedExpr))
+if any((i for i in [])): +if any((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])):
print(longline) print(longline)
-if env_base := os.environ.get("PYTHONUSERBASE", None): -if env_base := os.environ.get("PYTHONUSERBASE", None):
+if NOT_YET_IMPLEMENTED_ExprNamedExpr: +if NOT_YET_IMPLEMENTED_ExprNamedExpr:
@ -150,7 +150,7 @@ if (NOT_YET_IMPLEMENTED_ExprNamedExpr) is None:
if NOT_YET_IMPLEMENTED_ExprNamedExpr: if NOT_YET_IMPLEMENTED_ExprNamedExpr:
pass pass
[NOT_YET_IMPLEMENTED_ExprNamedExpr, y**2, y**3] [NOT_YET_IMPLEMENTED_ExprNamedExpr, y**2, y**3]
filtered_data = [i for i in []] filtered_data = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
(NOT_YET_IMPLEMENTED_ExprNamedExpr) (NOT_YET_IMPLEMENTED_ExprNamedExpr)
y0 = NOT_YET_IMPLEMENTED_ExprNamedExpr y0 = NOT_YET_IMPLEMENTED_ExprNamedExpr
foo(x=(NOT_YET_IMPLEMENTED_ExprNamedExpr)) foo(x=(NOT_YET_IMPLEMENTED_ExprNamedExpr))
@ -176,7 +176,7 @@ x = NOT_YET_IMPLEMENTED_ExprNamedExpr
len(NOT_YET_IMPLEMENTED_ExprNamedExpr) len(NOT_YET_IMPLEMENTED_ExprNamedExpr)
foo(NOT_YET_IMPLEMENTED_ExprNamedExpr, cat="vector") foo(NOT_YET_IMPLEMENTED_ExprNamedExpr, cat="vector")
foo(cat=(NOT_YET_IMPLEMENTED_ExprNamedExpr)) foo(cat=(NOT_YET_IMPLEMENTED_ExprNamedExpr))
if any((i for i in [])): if any((NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])):
print(longline) print(longline)
if NOT_YET_IMPLEMENTED_ExprNamedExpr: if NOT_YET_IMPLEMENTED_ExprNamedExpr:
return env_base return env_base

View file

@ -248,9 +248,9 @@ instruction()#comment with bad spacing
- # right - # right
- if element is not None - if element is not None
- ] - ]
+ lcomp = [i for i in []] + lcomp = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+ lcomp2 = [i for i in []] + lcomp2 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+ lcomp3 = [i for i in []] + lcomp3 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
while True: while True:
if False: if False:
continue continue
@ -404,9 +404,9 @@ short
# yup # yup
arg3=True, arg3=True,
) )
lcomp = [i for i in []] lcomp = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
lcomp2 = [i for i in []] lcomp2 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
lcomp3 = [i for i in []] lcomp3 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
while True: while True:
if False: if False:
continue continue

View file

@ -72,7 +72,7 @@ def func():
- # right - # right
- if element is not None - if element is not None
- ] - ]
+ lcomp3 = [i for i in []] + lcomp3 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
# Capture each of the exceptions in the MultiError along with each of their causes and contexts # Capture each of the exceptions in the MultiError along with each of their causes and contexts
if isinstance(exc_value, MultiError): if isinstance(exc_value, MultiError):
embedded = [] embedded = []
@ -98,7 +98,7 @@ def func():
x = """ x = """
a really long string a really long string
""" """
lcomp3 = [i for i in []] lcomp3 = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
# Capture each of the exceptions in the MultiError along with each of their causes and contexts # Capture each of the exceptions in the MultiError along with each of their causes and contexts
if isinstance(exc_value, MultiError): if isinstance(exc_value, MultiError):
embedded = [] embedded = []

View file

@ -384,10 +384,10 @@ last_call()
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} +{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} +{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} +{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
+[i for i in []] +[NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+[i for i in []] +[NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+[i for i in []] +[NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+[i for i in []] +[NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} +{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} +{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} +{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
@ -486,10 +486,10 @@ last_call()
-((i**2) for i, _ in ((1, "a"), (2, "b"), (3, "c"))) -((i**2) for i, _ in ((1, "a"), (2, "b"), (3, "c")))
-(((i**2) + j) for i in (1, 2, 3) for j in (1, 2, 3)) -(((i**2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
-(*starred,) -(*starred,)
+(i for i in []) +(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+(i for i in []) +(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+(i for i in []) +(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+(i for i in []) +(NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
+(*NOT_YET_IMPLEMENTED_ExprStarred,) +(*NOT_YET_IMPLEMENTED_ExprStarred,)
{ {
"id": "1", "id": "1",
@ -507,7 +507,7 @@ last_call()
) )
what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set( what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
vars_to_remove vars_to_remove
-) )
-result = ( -result = (
- session.query(models.Customer.id) - session.query(models.Customer.id)
- .filter( - .filter(
@ -515,7 +515,7 @@ last_call()
- ) - )
- .order_by(models.Customer.id.asc()) - .order_by(models.Customer.id.asc())
- .all() - .all()
) -)
-result = ( -result = (
- session.query(models.Customer.id) - session.query(models.Customer.id)
- .filter( - .filter(
@ -537,7 +537,7 @@ last_call()
Ø = set() Ø = set()
authors.łukasz.say_thanks() authors.łukasz.say_thanks()
mapping = { mapping = {
@@ -237,29 +231,27 @@ @@ -237,29 +231,29 @@
def gen(): def gen():
@ -574,11 +574,13 @@ last_call()
for y in (): for y in ():
... ...
-for z in (i for i in (1, 2, 3)): -for z in (i for i in (1, 2, 3)):
+for z in (i for i in []): +for (
+ z
+) in (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []):
... ...
for i in call(): for i in call():
... ...
@@ -328,13 +320,18 @@ @@ -328,13 +322,18 @@
): ):
return True return True
if ( if (
@ -600,7 +602,7 @@ last_call()
^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
): ):
return True return True
@@ -342,7 +339,8 @@ @@ -342,7 +341,8 @@
~aaaaaaaaaaaaaaaa.a ~aaaaaaaaaaaaaaaa.a
+ aaaaaaaaaaaaaaaa.b + aaaaaaaaaaaaaaaa.b
- aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
@ -714,10 +716,10 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
[i for i in []] [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
[i for i in []] [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
[i for i in []] [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
[i for i in []] [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
@ -802,10 +804,10 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
(SomeName) (SomeName)
SomeName SomeName
(Good, Bad, Ugly) (Good, Bad, Ugly)
(i for i in []) (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
(i for i in []) (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
(i for i in []) (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
(i for i in []) (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
(*NOT_YET_IMPLEMENTED_ExprStarred,) (*NOT_YET_IMPLEMENTED_ExprStarred,)
{ {
"id": "1", "id": "1",
@ -868,7 +870,9 @@ for (x,) in (1,), (2,), (3,):
... ...
for y in (): for y in ():
... ...
for z in (i for i in []): for (
z
) in (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []):
... ...
for i in call(): for i in call():
... ...

View file

@ -87,7 +87,7 @@ return np.divide(
i = funcs.f() ** 5 i = funcs.f() ** 5
j = super().name ** 5 j = super().name ** 5
-k = [(2**idx, value) for idx, value in pairs] -k = [(2**idx, value) for idx, value in pairs]
+k = [i for i in []] +k = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001) l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
m = [([2**63], [1, 2**63])] m = [([2**63], [1, 2**63])]
n = count <= 10**5 n = count <= 10**5
@ -95,7 +95,7 @@ return np.divide(
-p = {(k, k**2): v**2 for k, v in pairs} -p = {(k, k**2): v**2 for k, v in pairs}
-q = [10**i for i in range(6)] -q = [10**i for i in range(6)]
+p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} +p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
+q = [i for i in []] +q = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
r = x**y r = x**y
a = 5.0**~4.0 a = 5.0**~4.0
@ -110,7 +110,7 @@ return np.divide(
i = funcs.f() ** 5.0 i = funcs.f() ** 5.0
j = super().name ** 5.0 j = super().name ** 5.0
-k = [(2.0**idx, value) for idx, value in pairs] -k = [(2.0**idx, value) for idx, value in pairs]
+k = [i for i in []] +k = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001) l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
m = [([2.0**63.0], [1.0, 2**63.0])] m = [([2.0**63.0], [1.0, 2**63.0])]
n = count <= 10**5.0 n = count <= 10**5.0
@ -118,7 +118,7 @@ return np.divide(
-p = {(k, k**2): v**2.0 for k, v in pairs} -p = {(k, k**2): v**2.0 for k, v in pairs}
-q = [10.5**i for i in range(6)] -q = [10.5**i for i in range(6)]
+p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} +p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
+q = [i for i in []] +q = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873) # WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
@ -164,13 +164,13 @@ g = a.b**c.d
h = 5 ** funcs.f() h = 5 ** funcs.f()
i = funcs.f() ** 5 i = funcs.f() ** 5
j = super().name ** 5 j = super().name ** 5
k = [i for i in []] k = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001) l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
m = [([2**63], [1, 2**63])] m = [([2**63], [1, 2**63])]
n = count <= 10**5 n = count <= 10**5
o = settings(max_examples=10**6) o = settings(max_examples=10**6)
p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
q = [i for i in []] q = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
r = x**y r = x**y
a = 5.0**~4.0 a = 5.0**~4.0
@ -183,13 +183,13 @@ g = a.b**c.d
h = 5.0 ** funcs.f() h = 5.0 ** funcs.f()
i = funcs.f() ** 5.0 i = funcs.f() ** 5.0
j = super().name ** 5.0 j = super().name ** 5.0
k = [i for i in []] k = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001) l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
m = [([2.0**63.0], [1.0, 2**63.0])] m = [([2.0**63.0], [1.0, 2**63.0])]
n = count <= 10**5.0 n = count <= 10**5.0
o = settings(max_examples=10**6.0) o = settings(max_examples=10**6.0)
p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict} p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
q = [i for i in []] q = [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873) # WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)

View file

@ -43,7 +43,7 @@ ham[lower + offset : upper + offset]
```diff ```diff
--- Black --- Black
+++ Ruff +++ Ruff
@@ -4,28 +4,28 @@ @@ -4,28 +4,34 @@
slice[d::d] slice[d::d]
slice[0] slice[0]
slice[-1] slice[-1]
@ -65,13 +65,19 @@ ham[lower + offset : upper + offset]
slice[not so_simple : 1 < val <= 10] slice[not so_simple : 1 < val <= 10]
-slice[(1 for i in range(42)) : x] -slice[(1 for i in range(42)) : x]
-slice[:: [i for i in range(42)]] -slice[:: [i for i in range(42)]]
+slice[(i for i in []) : x] +slice[
+slice[ :: [i for i in []]] + (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []) : x
+]
+slice[
+ :: [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
+]
async def f(): async def f():
- slice[await x : [i async for i in arange(42)] : 42] - slice[await x : [i async for i in arange(42)] : 42]
+ slice[await x : [i for i in []] : 42] + slice[
+ await x : [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []] : 42
+ ]
# These are from PEP-8: # These are from PEP-8:
@ -103,12 +109,18 @@ slice[lambda x: True : lambda x: True]
slice[lambda x: True :, None::] slice[lambda x: True :, None::]
slice[1 or 2 : True and False] slice[1 or 2 : True and False]
slice[not so_simple : 1 < val <= 10] slice[not so_simple : 1 < val <= 10]
slice[(i for i in []) : x] slice[
slice[ :: [i for i in []]] (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []) : x
]
slice[
:: [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
]
async def f(): async def f():
slice[await x : [i for i in []] : 42] slice[
await x : [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []] : 42
]
# These are from PEP-8: # These are from PEP-8:

View file

@ -277,8 +277,14 @@ aaaaaaaaaaaaaa + {
dddddddddddddddd, dddddddddddddddd,
eeeeeee, eeeeeee,
} }
aaaaaaaaaaaaaa + [i for i in []] (
aaaaaaaaaaaaaa + (i for i in []) aaaaaaaaaaaaaa
+ [NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []]
)
(
aaaaaaaaaaaaaa
+ (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in [])
)
aaaaaaaaaaaaaa + {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set} aaaaaaaaaaaaaa + {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
# Wraps it in parentheses if it needs to break both left and right # Wraps it in parentheses if it needs to break both left and right

View file

@ -121,7 +121,7 @@ with (
# currently unparsable by black: https://github.com/psf/black/issues/3678 # currently unparsable by black: https://github.com/psf/black/issues/3678
with (i for i in []): with (NOT_YET_IMPLEMENTED_generator_key for NOT_YET_IMPLEMENTED_generator_key in []):
pass pass
with (a, *NOT_YET_IMPLEMENTED_ExprStarred): with (a, *NOT_YET_IMPLEMENTED_ExprStarred):
pass pass