PyCQA / flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://flake8.pycqa.org
Other
3.39k stars 306 forks source link

E713 thrown for f-strings #1924

Closed YigitElma closed 5 months ago

YigitElma commented 5 months ago

how did you install flake8?

conda install 
flake8 >= 5.0.0, <6.0.0
flake8-docstrings >= 1.0.0, <2.0.0
flake8-eradicate >= 1.0.0, <2.0.0
flake8-isort >=5.0.0, < 6.0.0

unmodified output of flake8 --bug-report

E713

describe the problem

params = ["a", "b", "c"]
check = ["a", 'b", "d"]
for par in params:
    errorif(
        par not in check,
        ValueError,
        f"parameter {par} not found in optimizable_parameters: "
        + f"{check}",
    )

When I try to commit this code, flake8 throws E713 error, although the requirement is satisfied. However, if I change only the f-string of the code like this,

params = ["a", "b", "c"]
check = ["a", 'b", "d"]
for par in params:
    errorif(
        par not in check,
        ValueError,
        f"parameter {par} not in found in optimizable_parameters: "
        + f"{check}",
    )

It doesn't complain about "not ...... in" anymore. I can use another error message but I wanted to report this bug. My flake8 version is 5.0.4

asottile commented 5 months ago

please read the issue template and the prompts before it

biendltb commented 3 months ago

Just hit the same issue. Flake8 should skip the check for strings.

asottile commented 3 months ago

it should and does and if you read the issue template and follow what it says including some very simple debugging steps you'll find the answer is self inflicted and be and to fix it for yourself