PyCQA / pyflakes

A simple program which checks Python source files for errors
https://pypi.org/project/pyflakes
MIT License
1.36k stars 178 forks source link

False-positive F811 #805

Closed Kein closed 6 months ago

Kein commented 6 months ago

flake8==7.0.0

Consider the following: main.py:

from typing import Any, Optional, TYPE_CHECKING
if TYPE_CHECKING:
    from toolbox import inject_css_safe

    # bleh
    # later in code used as
    inject_css_safe("ablooo")

toolbox.py: (gets appended to main.py )

def inject_css_safe(whatever: str):
    #bleh-blah

In the final merged file: redefinition of unused 'inject_css_safe' from line 9Flake8(F811)

While the setup is unusual, the bug is still valid. Only flake8/pyflake reports this issue, mypy, pylint and Pylance are silent as a buddha.

asottile commented 6 months ago

dupe #715