PyCQA / pycodestyle

Simple Python style checker in one Python file

Home Page:https://pycodestyle.pycqa.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

f-string varialbes shows wrong E251 and E202 since python 3.12 upgrade

gituser789 opened this issue · comments

Since upgrading to python 3.12, there are new hints, which have not been there using pycodestyle together with python 3.11:

print(f"{my_variable = }")

raises

E251 unexpected spaces around keyword / parameter equals
E202 whitespace before '}'

As it makes a difference in displaying, for different formats, there are different display outputs with/without spaces
print(f"{my_variable = }") -> my_variable = 5
print(f"{my_variable=}") -> my_variable=5

In the f-string case, the spaces are wanted.
When ignoring E251 and E202, the hints are missing in real functions if the space is missing.

please search for duplicates

Sorry, was not aware of the wanted behavior, since it wasn't in older versions using the same code. Duplicates:
#1190
#1201
#1224