Skip to content
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

E202 complains about meaningful space before parenthesis in f-strings debug expressions #1250

Closed
nj-vs-vh opened this issue Jul 8, 2024 · 1 comment

Comments

@nj-vs-vh
Copy link

nj-vs-vh commented Jul 8, 2024

Consider the following code using debug-expressions in f-strings. Here's the PEP that seeks to retroactively codify them and gives some links to their description.

var = 123
print(f"{var=}")
print(f"{var = }")

It produces the following output:

var=123
var = 123

As one can see, the spaces around the "=" sign are not a code formatting choice, but rather a part of the debug format. Hence, pycodestyle should probably ignore them. However, it currently thinks that it's a formatting error:

mre.py:3:13: E251 unexpected spaces around keyword / parameter equals
mre.py:3:15: E202 whitespace before '}'
mre.py:3:15: E251 unexpected spaces around keyword / parameter equals

I am extensively using these expressions in many projects and having to manually ignore E202 and E251 every time is a bit of a hassle!

@asottile
Copy link
Member

asottile commented Jul 8, 2024

please search for duplicates there are several exact ones!

@asottile asottile closed this as completed Jul 8, 2024
@PyCQA PyCQA locked as off-topic and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants