-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Description
Rules
TCH category includes:
- TCH001: Move import into TYPE_CHECKING block (used only for annotations)
- TCH002: Move import out of TYPE_CHECKING block (needed at runtime)
- TCH003: Move stdlib import into TYPE_CHECKING block
Purpose
Ensure correct usage of TYPE_CHECKING blocks:
- Imports only used for type annotations should be in TYPE_CHECKING
- Imports needed at runtime should NOT be in TYPE_CHECKING
- Properly separates annotation-only imports from runtime imports
Benefits
- Faster import times (annotation-only imports not loaded at runtime)
- Accurate transitive dependency detection in lint/check/test
- Prevents runtime errors from imports that should be in TYPE_CHECKING
- Catches runtime-evaluated values incorrectly placed in TYPE_CHECKING
Auto-fix
✅ Available
Notes
- Critical for correct pants
--changed-dependents=transitivebehavior - Helps with circular import prevention
JIRA Issue: BA-4023
Metadata
Metadata
Assignees
Labels
No labels