Registry / testing / flake8-typing-imports

flake8-typing-imports

JSON →
library1.17.0pypypiunverified

Flake8 plugin enforcing that typing imports are guarded by `if TYPE_CHECKING` to avoid runtime import overhead and circular imports. Current version 1.17.0, requires Python >=3.9. Maintained by asottile, stable release cadence.

pip install flake8-typing-imports
INSTALL
IMPORT
SIG · FLAKE8-TYPING-IMPO
F
flake8-typing-imports
testingpythonv1.17.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

flake8_typing_imports
flaek8 loads plugins automatically; no manual import needed.

Create a file with a guarded import and run flake8 with the TYP selector to check typing imports.

cat > example.py << 'EOF' from typing import TYPE_CHECKING if TYPE_CHECKING: from collections import abc foo: abc.Iterable EOF pip install flake8 flake8-typing-imports flake8 example.py --select=TYP
Debug
Known issues
breakingIn version 1.6.0, the default codes changed from TYP001, TYP002 etc. to a new scheme. Old codes may no longer be valid.
fix
Update your flake8 configuration to use the new codes (TYP001, TYP002, etc. are still supported but deprecated). See changelog.
affects: <1.6.0
gotchaThe plugin checks for `TYPE_CHECKING` guard on imports of `typing` and `collections.abc`, but it does not flag other modules like `types`. You must manually guard them.
fix
Manually guard imports from modules like `types` if needed.
affects: all
gotchaThe plugin only detects `from foo import bar` guarded imports; bare imports like `import foo` inside `if TYPE_CHECKING` are not flagged if they are not from typing-related modules.
fix
Ensure all typing imports use `from ... import ...` syntax if guarding.
affects: all
deprecatedSupport for Python 3.7 ended in version 1.15.0; Python 3.8 ended in 1.16.0. Running on older Python versions will not work.
fix
Upgrade to Python >=3.9.
affects: >=1.15.0
Upgrade
Version history
1.17.0latest on PyPI · released Oct 9, 2025
Audit
Dependencies
flake8requiredPlugin is loaded by flake8; must be installed alongside flake8.
Agent activity
30 hits · last 30 days
node
22
OpenAI (training)
1
Resources
flake8-typing-imports — pip install flake8-typing-imports · libregistry