You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ruff check --target-version=py310 --select=Q foo.py foo.py:2:34: Q000 [*] Single quotes found but double quotes preferred
--- foo.py+++ foo.py@@ -1,2 +1,2 @@
x = y = z = 5
-s = f"Before {f'x {x}' if y else f'foo {z}'} after"+s = f"Before {f'x {x}' if y else f"foo {z}"} after"
After applying --fix
$ python3.10 foo.py File "foo.py", line 2 s = f"Before {f'x {x}' if y else f"foo {z}"} after" ^^^SyntaxError: f-string: expecting '}'
Notes:
The "fixed" syntax is only valid in 3.12 because it supports arbitrarily nested fstrings
I cannot reproduce this bad fix using ruff 0.1.6
The text was updated successfully, but these errors were encountered:
…l-sh#10766)
## Summary
This PR adds a new semantic model flag to indicate that the checker is
inside an f-string replacement field. This will be used to ignore
certain checks if the target version doesn't support a specific feature
like PEP 701.
fixes: astral-sh#10761
## Test Plan
Add a test case from the raised issue.
Using ruff 0.3.5: the fix for https://docs.astral.sh/ruff/rules/bad-quotes-inline-string/ results in a syntax error
After applying
--fix
Notes:
The text was updated successfully, but these errors were encountered: