{"id":23741,"library":"flake8-type-checking","title":"flake8-type-checking","description":"A flake8 plugin for managing type-checking imports and forward references. Current version 3.2.0, requires Python >=3.10. Released irregularly with multiple minor versions per year.","status":"active","version":"3.2.0","language":"python","source_language":"en","source_url":"https://github.com/snok/flake8-type-checking","tags":["flake8","type-checking","typing","linter","python"],"install":[{"cmd":"pip install flake8-type-checking","lang":"bash","label":"default"}],"dependencies":[{"reason":"Plugin runs as a flake8 extension","package":"flake8","optional":false}],"imports":[{"note":"Hyphens not allowed in Python imports; use underscores","wrong":"import flake8-type-checking","symbol":"flake8_type_checking","correct":"from flake8_type_checking import ..."}],"quickstart":{"code":"# file: setup.cfg or .flake8\n[flake8]\nextend-ignore = TC001,TC002  # adjust as needed\n\n# file: example.py\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from foo import Bar  # acceptable if only used in type hints\n\ndef greet() -> None:\n    # Use Bar here? Actually, only for type checking\n    pass\n","lang":"python","description":"Basic usage: install and configure flake8, then add ignore or error codes as needed. The plugin automatically detects TYPE_CHECKING blocks."},"warnings":[{"fix":"Add `type-checking-typing-modules = mymodule.typing` to your flake8 config, where `mymodule.typing` is the module that re-exports.","message":"v3.0.0 broke detection of re-exported typing symbols like `cast` and `Annotated` from non-typing modules. You must configure `type-checking-typing-modules` if you re-export them.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always import TYPE_CHECKING from typing, not from other modules.","message":"The plugin treats `TYPE_CHECKING` blocks specially; ordinary conditional imports (e.g., `if False:`) are not recognized. Only `from typing import TYPE_CHECKING` (or `typing.TYPE_CHECKING`) triggers the plugin's logic.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.10 or later.","message":"Python 3.8 support dropped in v3.0.0; Python 3.10+ required.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use `from __future__ import annotations` or convert string annotations to actual type hints, or disable TC010 with `extend-ignore = TC010`.","message":"TC010 (invalid use of string literals with `|`) was added in v2.9.0. It flags union types as strings even when they are syntactically valid in Python 3.10+. This may cause false positives for type annotations that are not evaluated at runtime.","severity":"gotcha","affected_versions":">=2.9.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Move the import inside an `if TYPE_CHECKING:` block.","cause":"Import that is only used in type annotations is not inside a TYPE_CHECKING block.","error":"tc001: import move to type-checking block"},{"fix":"Use `if TYPE_CHECKING:` for the type-only part and a separate runtime import if needed, or add a `# noqa: TC002` comment.","cause":"Similar to TC001, but for symbols that are used both as type hints and at runtime. The plugin suggests splitting imports.","error":"tc002: import move to type-checking block (ignored by default)"},{"fix":"Move all such imports into an `if TYPE_CHECKING:` block.","cause":"Several imports are used only in type annotations but not wrapped.","error":"tc100: multiple type annotations to be moved to TYPE_CHECKING block"},{"fix":"Quote the annotation, e.g., `def foo() -> 'Bar':`","cause":"A type annotation references a name that hasn't been imported at runtime, but was not quoted.","error":"tc200: forward reference annotation should use string literal"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}