mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
move comments from expressions in f-strings out (#6481)
This commit is contained in:
parent
2cedb401bd
commit
f091b46497
3 changed files with 28 additions and 0 deletions
|
@ -24,3 +24,12 @@ result_f = (
|
|||
r' \[Previous line repeated (\d+) more times\]' '\n'
|
||||
'RecursionError: maximum recursion depth exceeded\n'
|
||||
)
|
||||
|
||||
|
||||
# Regression for fstring dropping comments that were accidentally attached to
|
||||
# an expression inside a formatted value
|
||||
(
|
||||
f'{1}'
|
||||
# comment
|
||||
''
|
||||
)
|
||||
|
|
|
@ -80,6 +80,7 @@ pub(super) fn place_comment<'a>(
|
|||
CommentPlacement::Default(comment)
|
||||
}
|
||||
}
|
||||
AnyNodeRef::ExprFString(fstring) => CommentPlacement::dangling(fstring, comment),
|
||||
AnyNodeRef::ExprList(_)
|
||||
| AnyNodeRef::ExprSet(_)
|
||||
| AnyNodeRef::ExprGeneratorExp(_)
|
||||
|
|
|
@ -30,6 +30,15 @@ result_f = (
|
|||
r' \[Previous line repeated (\d+) more times\]' '\n'
|
||||
'RecursionError: maximum recursion depth exceeded\n'
|
||||
)
|
||||
|
||||
|
||||
# Regression for fstring dropping comments that were accidentally attached to
|
||||
# an expression inside a formatted value
|
||||
(
|
||||
f'{1}'
|
||||
# comment
|
||||
''
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -58,6 +67,15 @@ result_f = (
|
|||
"\n"
|
||||
"RecursionError: maximum recursion depth exceeded\n"
|
||||
)
|
||||
|
||||
|
||||
# Regression for fstring dropping comments that were accidentally attached to
|
||||
# an expression inside a formatted value
|
||||
(
|
||||
f"{1}"
|
||||
# comment
|
||||
""
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue