mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
Fix placement for comments within f-strings concatenations (#7047)
## Summary Restores the dangling comment handling for f-strings, which broke with the parenthesized expression code. Closes https://github.com/astral-sh/ruff/issues/6898. ## Test Plan `cargo test` No change in any of the similarity indexes or changed file counts: | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1632 | | django | 0.99957 | 2760 | 67 | | transformers | 0.99927 | 2587 | 468 | | twine | 0.99982 | 33 | 1 | | typeshed | 0.99978 | 3496 | 2173 | | warehouse | 0.99818 | 648 | 24 | | zulip | 0.99942 | 1437 | 32 |
This commit is contained in:
parent
fbc9b5a604
commit
dea65536e9
3 changed files with 86 additions and 0 deletions
|
@ -39,6 +39,30 @@ result_f = (
|
|||
# comment
|
||||
''
|
||||
)
|
||||
|
||||
(
|
||||
f'{1}' # comment
|
||||
f'{2}'
|
||||
)
|
||||
|
||||
(
|
||||
f'{1}'
|
||||
f'{2}' # comment
|
||||
)
|
||||
|
||||
(
|
||||
1, ( # comment
|
||||
f'{2}'
|
||||
)
|
||||
)
|
||||
|
||||
(
|
||||
(
|
||||
f'{1}'
|
||||
# comment
|
||||
),
|
||||
2
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -76,6 +100,30 @@ result_f = (
|
|||
# comment
|
||||
""
|
||||
)
|
||||
|
||||
(
|
||||
f"{1}" # comment
|
||||
f"{2}"
|
||||
)
|
||||
|
||||
(
|
||||
f"{1}" f"{2}" # comment
|
||||
)
|
||||
|
||||
(
|
||||
1,
|
||||
( # comment
|
||||
f"{2}"
|
||||
),
|
||||
)
|
||||
|
||||
(
|
||||
(
|
||||
f"{1}"
|
||||
# comment
|
||||
),
|
||||
2,
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue