mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Fix can_omit_optional_parentheses
for expressions with a right most fstring (#9124)
This commit is contained in:
parent
b8fc006e52
commit
7256b882b9
3 changed files with 55 additions and 17 deletions
|
@ -319,6 +319,18 @@ expected_content = (
|
|||
)
|
||||
)
|
||||
|
||||
# Skip FString content when determining whether to omit optional parentheses or not.0
|
||||
# The below expression should be parenthesized because it ends with an fstring and starts with a name.
|
||||
# (Call expressions at the beginning don't count as parenthesized because they don't start with parens).
|
||||
assert (
|
||||
format.format_event(spec)
|
||||
== f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})'
|
||||
)
|
||||
# Avoid parentheses for this example because it starts with a tuple expression.
|
||||
assert (
|
||||
(spec, format)
|
||||
== f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})'
|
||||
)
|
||||
|
||||
rowuses = [(1 << j) | # column ordinal
|
||||
(1 << (n + i-j + n-1)) | # NW-SE ordinal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue