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.42k stars 306 forks source link

Imports used in "# type" are detected as unused in 6.0.0 #1755

Closed SamuilDichev closed 1 year ago

SamuilDichev commented 1 year ago

how did you install flake8?

$ pip install flake8==6.0.0

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.8.10",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.10.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.0.0"
    }
  ],
  "version": "6.0.0"
}

describe the problem

what I expected to happen

Imports used only for type hinting via # type to be detected as used and not be highlighted by flake8 as unused.

sample code

from typing import Dict
gaz = {}  # type: Dict[int, int]

commands ran

$ flake8 test/test.py
test/test.py:1:1: F401 'typing.Dict' imported but unused
sigmavirus24 commented 1 year ago

In the future, please search closed and open issues before creating new ones that are duplicates.