mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
Format trailing operator comments as dangling (#7427)
## Summary Given a trailing operator comment in a unary expression, like: ```python if ( not # comment a): ... ``` We were attaching these to the operand (`a`), but formatting them in the unary operator via special handling. Parents shouldn't format the comments of their children, so this instead attaches them as dangling comments on the unary expression. (No intended change in formatting.)
This commit is contained in:
parent
f4d50a2aec
commit
cc9e84c144
4 changed files with 73 additions and 37 deletions
|
@ -152,6 +152,11 @@ if (
|
|||
# comment
|
||||
a):
|
||||
...
|
||||
|
||||
if (
|
||||
not # comment
|
||||
a):
|
||||
...
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -317,6 +322,11 @@ if (
|
|||
a
|
||||
):
|
||||
...
|
||||
|
||||
if (
|
||||
not a # comment
|
||||
):
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue