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
cannot use --safe with this file; failed to parse source file AST: f-string: unterminated string (, line 2)
This could be caused by running Black with an older Python version that does not support new syntax used in your source file.
This is very similar to #4329 , but there the MRE seems to involve nested f-strings.
Additional context
Something like f'{'a'}' is valid code in python 3.12. See:
Black's AST safety check relies on Python's builtin AST library. If that is running on a version of Python before 3.12, this file won't parse. It will work fine if you run Black on Python 3.12 or higher.
Describe the bug
Black fails to format f-strings where the contents re-use the same quotes as the enclosing f-string.
f'{'a'}'
Running this inside of https://black.vercel.app/?version=main
yields this error:
This is very similar to #4329 , but there the MRE seems to involve nested f-strings.
Additional context
Something like
f'{'a'}'
is valid code in python 3.12. See:https://docs.python.org/3/whatsnew/3.12.html#pep-701-syntactic-formalization-of-f-strings
The text was updated successfully, but these errors were encountered: