-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use self-documenting f-strings where possible #4302
Comments
This would be nice, and would help make those who don't know this feature aware of it 🙂 The only snag is that f-strings are not part of the formal grammar until Python 3.12 - see PEP 701 - so they're tricky to do much with right now. Other test cases to include for unbalanced spacing: # bad (if target=py3.8+)
f"my_var= {my_var}"
f"my_var ={my_var}"
# good
f"{my_var= }"
f"{my_var =}" |
I think this is a |
Ah, this is made difficult by the fact that ruffpython-ast apparently already parses
so it's not easy to distinguish between already correctly formed expressions and those that need changing 🤔 |
Tbh I'm out of my depth on AST and grammar. At the risk of going against orthodoxy and sounding low-status, if the grammar doesn't formalize f-strings below 3.12, maybe a regex can help distinguish true positives? 😄 |
The two nodes differ in that the second has |
Python.asdl refers it as |
About this or not, please feel free to suggest anything I can make ast better. |
Could maybe be added to
flake8-simplify
.The text was updated successfully, but these errors were encountered: