mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
Format StmtExpr (#4788)
This commit is contained in:
parent
4cd4b37e74
commit
a401989b7a
4 changed files with 77 additions and 19 deletions
|
@ -109,7 +109,7 @@ async def wat():
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -8,27 +8,19 @@
|
||||
@@ -8,27 +8,17 @@
|
||||
|
||||
Possibly also many, many lines.
|
||||
"""
|
||||
|
@ -128,16 +128,18 @@ async def wat():
|
|||
-
|
||||
-# Some comment before a function.
|
||||
y = 1
|
||||
(
|
||||
# some strings
|
||||
y # type: ignore
|
||||
)
|
||||
-(
|
||||
- # some strings
|
||||
- y # type: ignore
|
||||
-)
|
||||
-
|
||||
-
|
||||
+# some strings
|
||||
+y # type: ignore
|
||||
def function(default=None):
|
||||
"""Docstring comes first.
|
||||
|
||||
@@ -45,12 +37,8 @@
|
||||
@@ -45,12 +35,8 @@
|
||||
|
||||
# This return is also commented for some reason.
|
||||
return default
|
||||
|
@ -150,7 +152,7 @@ async def wat():
|
|||
# Another comment!
|
||||
# This time two lines.
|
||||
|
||||
@@ -73,8 +61,6 @@
|
||||
@@ -73,8 +59,6 @@
|
||||
|
||||
self.spam = 4
|
||||
"""Docstring for instance attribute spam."""
|
||||
|
@ -159,7 +161,7 @@ async def wat():
|
|||
#' <h1>This is pweave!</h1>
|
||||
|
||||
|
||||
@@ -93,4 +79,4 @@
|
||||
@@ -93,4 +77,4 @@
|
||||
|
||||
# Some closing comments.
|
||||
# Maybe Vim or Emacs directives for formatting.
|
||||
|
@ -190,10 +192,8 @@ try:
|
|||
except ImportError:
|
||||
import slow as fast
|
||||
y = 1
|
||||
(
|
||||
# some strings
|
||||
y # type: ignore
|
||||
)
|
||||
# some strings
|
||||
y # type: ignore
|
||||
def function(default=None):
|
||||
"""Docstring comes first.
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ 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}}
|
||||
+((super_long_variable_name or None) if (1 if super_long_test_name else 2) else (str or bytes or None))
|
||||
+(super_long_variable_name or None) if (1 if super_long_test_name else 2) else (str or bytes or None)
|
||||
+{'2.7': dead, '3.7': (long_live or die_hard)}
|
||||
+{'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
|
||||
{**a, **b, **c}
|
||||
|
@ -450,8 +450,9 @@ last_call()
|
|||
+{'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]
|
||||
(SomeName)
|
||||
-(SomeName)
|
||||
SomeName
|
||||
+SomeName
|
||||
(Good, Bad, Ugly)
|
||||
(i for i in (1, 2, 3))
|
||||
-((i**2) for i in (1, 2, 3))
|
||||
|
@ -735,7 +736,7 @@ str or None if True else str or bytes or None
|
|||
(str or None) if True else (str or bytes or None)
|
||||
str or None if (1 if True else 2) else str or bytes or None
|
||||
(str or None) if (1 if True else 2) else (str or bytes or None)
|
||||
((super_long_variable_name or None) if (1 if super_long_test_name else 2) else (str or bytes or None))
|
||||
(super_long_variable_name or None) if (1 if super_long_test_name else 2) else (str or bytes or None)
|
||||
{'2.7': dead, '3.7': (long_live or die_hard)}
|
||||
{'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
|
||||
{**a, **b, **c}
|
||||
|
@ -832,7 +833,7 @@ numpy[np.newaxis, :]
|
|||
{'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]
|
||||
(SomeName)
|
||||
SomeName
|
||||
SomeName
|
||||
(Good, Bad, Ugly)
|
||||
(i for i in (1, 2, 3))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue