mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
Avoid hard line break after dangling open-parenthesis comments (#6380)
## Summary Given: ```python [ # comment first, second, third ] # another comment ``` We were adding a hard line break as part of the formatting of `# comment`, which led to the following formatting: ```python [first, second, third] # comment # another comment ``` Closes https://github.com/astral-sh/ruff/issues/6367.
This commit is contained in:
parent
63692b3798
commit
b763973357
6 changed files with 82 additions and 18 deletions
|
@ -33,18 +33,19 @@ print( "111" ) # type: ignore
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,10 +1,8 @@
|
||||
@@ -1,12 +1,6 @@
|
||||
# This is a regression test. Issue #3737
|
||||
|
||||
-a = ( # type: ignore
|
||||
+a = int( # type: ignore # type: ignore
|
||||
int( # type: ignore
|
||||
- int( # type: ignore
|
||||
- int( # type: ignore
|
||||
- int(6) # type: ignore
|
||||
- )
|
||||
+ int(6) # type: ignore
|
||||
)
|
||||
)
|
||||
- )
|
||||
-)
|
||||
+a = int(int(int(6))) # type: ignore # type: ignore # type: ignore # type: ignore
|
||||
|
||||
b = int(6)
|
||||
|
||||
```
|
||||
|
||||
|
@ -53,11 +54,7 @@ print( "111" ) # type: ignore
|
|||
```py
|
||||
# This is a regression test. Issue #3737
|
||||
|
||||
a = int( # type: ignore # type: ignore
|
||||
int( # type: ignore
|
||||
int(6) # type: ignore
|
||||
)
|
||||
)
|
||||
a = int(int(int(6))) # type: ignore # type: ignore # type: ignore # type: ignore
|
||||
|
||||
b = int(6)
|
||||
|
||||
|
|
|
@ -50,6 +50,12 @@ c1 = [ # trailing open bracket
|
|||
[ # end-of-line comment
|
||||
1
|
||||
]
|
||||
|
||||
[ # inner comment
|
||||
first,
|
||||
second,
|
||||
third
|
||||
] # outer comment
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -94,6 +100,8 @@ c1 = [ # trailing open bracket
|
|||
]
|
||||
|
||||
[1] # end-of-line comment
|
||||
|
||||
[first, second, third] # inner comment # outer comment
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue