Skip to content

Commit

Permalink
Don't handle extra comments and all long strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Jul 13, 2023
1 parent 5c4cf3d commit e1bfaa8
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Dangle2
)

# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
Expand All @@ -17,6 +18,7 @@

# Random dangler

# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,29 +316,23 @@ long_unmergable_string_with_pragma = (

comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top.

@@ -165,14 +165,14 @@
@@ -165,13 +165,9 @@

triple_quote_string = """This is a really really really long triple quote string assignment and it should not be touched."""

-assert (
- some_type_of_boolean_expression
-), "Followed by a really really really long string that is used to provide context to the AssertionError exception."
+assert some_type_of_boolean_expression, (
+ "Followed by a really really really long string that is used to provide context to the AssertionError exception."
+)
+assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception."

-assert (
- some_type_of_boolean_expression
-), "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format(
- "formatting"
+assert some_type_of_boolean_expression, (
+ "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format(
+ "formatting"
+ )
+assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format(
"formatting"
)

assert some_type_of_boolean_expression, (
@@ -221,8 +221,8 @@
@@ -221,8 +217,8 @@
func_with_bad_comma(
(
"This is a really long string argument to a function that has a trailing comma"
Expand All @@ -349,7 +343,7 @@ long_unmergable_string_with_pragma = (
)

func_with_bad_parens_that_wont_fit_in_one_line(
@@ -271,10 +271,10 @@
@@ -271,10 +267,10 @@


def foo():
Expand Down Expand Up @@ -534,14 +528,10 @@ pragma_comment_string2 = "Lines which end with an inline pragma comment of the f

triple_quote_string = """This is a really really really long triple quote string assignment and it should not be touched."""

assert some_type_of_boolean_expression, (
"Followed by a really really really long string that is used to provide context to the AssertionError exception."
)
assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception."

assert some_type_of_boolean_expression, (
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format(
"formatting"
)
assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format(
"formatting"
)

assert some_type_of_boolean_expression, (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,18 @@ class C:
print(i)
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
push_manager=context.request.resource_manager,
@@ -153,7 +153,8 @@
@@ -120,9 +120,7 @@
key7: value7,
key8: value8,
key9: value9,
- } == expected, (
- "Not what we expected and the message is too long to fit in one line"
- )
+ } == expected, "Not what we expected and the message is too long to fit in one line"
assert expected(
value, is_going_to_be="too long to fit in a single line", srsly=True
@@ -153,7 +151,8 @@
" because it's too long"
)
Expand All @@ -213,7 +224,7 @@ class C:
%3d 0 LOAD_FAST 1 (x)
2 LOAD_CONST 1 (1)
4 COMPARE_OP 2 (==)
@@ -161,8 +162,8 @@
@@ -161,8 +160,8 @@
8 STORE_ATTR 0 (x)
10 LOAD_CONST 0 (None)
12 RETURN_VALUE
Expand Down Expand Up @@ -351,9 +362,7 @@ class C:
key7: value7,
key8: value8,
key9: value9,
} == expected, (
"Not what we expected and the message is too long to fit in one line"
)
} == expected, "Not what we expected and the message is too long to fit in one line"
assert expected(
value, is_going_to_be="too long to fit in a single line", srsly=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,18 @@ class C:
print(i)
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
push_manager=context.request.resource_manager,
@@ -153,7 +153,8 @@
@@ -120,9 +120,7 @@
key7: value7,
key8: value8,
key9: value9,
- } == expected, (
- "Not what we expected and the message is too long to fit in one line"
- )
+ } == expected, "Not what we expected and the message is too long to fit in one line"
assert expected(
value, is_going_to_be="too long to fit in a single line", srsly=True
@@ -153,7 +151,8 @@
" because it's too long"
)
Expand All @@ -213,7 +224,7 @@ class C:
%3d 0 LOAD_FAST 1 (x)
2 LOAD_CONST 1 (1)
4 COMPARE_OP 2 (==)
@@ -161,8 +162,8 @@
@@ -161,8 +160,8 @@
8 STORE_ATTR 0 (x)
10 LOAD_CONST 0 (None)
12 RETURN_VALUE
Expand Down Expand Up @@ -351,9 +362,7 @@ class C:
key7: value7,
key8: value8,
key9: value9,
} == expected, (
"Not what we expected and the message is too long to fit in one line"
)
} == expected, "Not what we expected and the message is too long to fit in one line"
assert expected(
value, is_going_to_be="too long to fit in a single line", srsly=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def g():
return DOUBLESPACE
- assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
+ assert p is not None, NOT_YET_IMPLEMENTED_ExprJoinedStr
+ assert p is not None, f"NOT_YET_IMPLEMENTED_ExprJoinedStr"
prev = leaf.prev_sibling
if not prev:
Expand All @@ -126,7 +126,7 @@ def g():
# Another comment because more comments
- assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
+ assert p is not None, NOT_YET_IMPLEMENTED_ExprJoinedStr
+ assert p is not None, f"NOT_YET_IMPLEMENTED_ExprJoinedStr"
prev = leaf.prev_sibling
if not prev:
Expand All @@ -153,7 +153,7 @@ def f():
if t == token.COMMENT: # another trailing comment
return DOUBLESPACE
assert p is not None, NOT_YET_IMPLEMENTED_ExprJoinedStr
assert p is not None, f"NOT_YET_IMPLEMENTED_ExprJoinedStr"
prev = leaf.prev_sibling
if not prev:
Expand Down Expand Up @@ -203,7 +203,7 @@ def g():
return DOUBLESPACE
# Another comment because more comments
assert p is not None, NOT_YET_IMPLEMENTED_ExprJoinedStr
assert p is not None, f"NOT_YET_IMPLEMENTED_ExprJoinedStr"
prev = leaf.prev_sibling
if not prev:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,18 @@ last_call()
(*starred,)
{
"id": "1",
@@ -207,25 +207,15 @@
)
@@ -208,24 +208,14 @@
what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
vars_to_remove
-)
)
-result = (
- session.query(models.Customer.id)
- .filter(
- models.Customer.account_id == account_id, models.Customer.email == email_address
- )
- .order_by(models.Customer.id.asc())
- .all()
)
-)
-result = (
- session.query(models.Customer.id)
- .filter(
Expand Down Expand Up @@ -447,11 +446,7 @@ last_call()
async def f():
<<<<<<< HEAD
@@ -248,8 +238,12 @@
=======
@@ -248,18 +238,20 @@
>>>>>>> main
print(*[] or [1])
Expand All @@ -466,7 +461,7 @@ last_call()
assert not Test, "Short message"
assert this is ComplexTest and not requirements.fit_in_a_single_line(
force=False
@@ -259,7 +253,9 @@
@@ -259,7 +253,7 @@
...
for y in ():
...
Expand All @@ -475,11 +470,7 @@ last_call()
...
for i in call():
...
<<<<<<< HEAD
@@ -328,13 +324,18 @@
=======
@@ -328,13 +320,18 @@
>>>>>>> main
@@ -328,13 +322,18 @@
):
return True
if (
Expand All @@ -501,11 +492,7 @@ last_call()
^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
):
return True
<<<<<<< HEAD
@@ -342,7 +343,8 @@
=======
@@ -342,7 +339,8 @@
>>>>>>> main
@@ -342,7 +341,8 @@
~aaaaaaaaaaaaaaaa.a
+ aaaaaaaaaaaaaaaa.b
- aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,14 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
# Example from https://github.com/psf/black/issues/3229
@@ -37,14 +35,7 @@
# Edge case where a bug in a working-in-progress version of
# https://github.com/psf/black/pull/3370 causes an infinite recursion.
-assert (
- long_module.long_class.long_func().another_func()
- == long_module.long_class.long_func()["some_key"].another_func(arg1)
-)
+NOT_YET_IMPLEMENTED_StmtAssert
@@ -45,6 +43,4 @@
# Regression test for https://github.com/psf/black/issues/3414.
-assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
- xxxxxxxxx
assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
xxxxxxxxx
-).xxxxxxxxxxxxxxxxxx(), (
- "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-)
+NOT_YET_IMPLEMENTED_StmtAssert
+).xxxxxxxxxxxxxxxxxx(), "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Ruff Output
Expand Down Expand Up @@ -115,10 +106,15 @@ def refresh_token(self, device_family, refresh_token, api_key):
# Edge case where a bug in a working-in-progress version of
# https://github.com/psf/black/pull/3370 causes an infinite recursion.
NOT_YET_IMPLEMENTED_StmtAssert
assert (
long_module.long_class.long_func().another_func()
== long_module.long_class.long_func()["some_key"].another_func(arg1)
)
# Regression test for https://github.com/psf/black/issues/3414.
NOT_YET_IMPLEMENTED_StmtAssert
assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
xxxxxxxxx
).xxxxxxxxxxxxxxxxxx(), "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Black Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ assert ( # Dangle1
# Dangle2
)
# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
Expand All @@ -23,6 +24,7 @@ assert (
# Random dangler
# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
Expand All @@ -39,33 +41,33 @@ assert (
assert True # Trailing same-line
assert True is True # Trailing same-line
assert 1, "Some string" # Trailing same-line
assert (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
) # Trailing same-line
assert aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # Trailing same-line
assert ( # Dangle1
# Dangle2
)
# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
True # Trailing test value same-line
# Trailing test value own-line
), (
# Trailing test value own-line
"Some string"
) # Trailing msg same-line
# Trailing assert
# Random dangler
# TODO: https://github.com/astral-sh/ruff/pull/5168#issuecomment-1630767421
# Leading assert
assert (
# Leading test value
True # Trailing test value same-line
), (
# Trailing test value own-line
# Test dangler
), (
"Some string"
) # Trailing msg same-line
# Trailing assert
Expand Down

0 comments on commit e1bfaa8

Please sign in to comment.