perf: Conditional imports for dependencies only used for type checks
Metadata
Current evaluation
Merged after approval by three reviewers and passing all CI checks. The PR adds linter rules for type-check-only imports and implements deferred imports to optimize runtime performance.
Suggested action: —
No scores available.
Issue body
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you added an entry to the changelog (`docs/reference/changelog.rst`)?
-----
Add 3 linter rules to check for imports for dependencies only used for type checks.
Fixes errors found by these rules (and 2 other unrelated lint errors).
Also rely on deferred type checking to import some deps only for type checking. These are not currently helping to reduce import time (because the same deps are imported in other modules) but I am experimenting to see if we could foster this habit and over time avoid some imports at runtime.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged after approval by three reviewers and passing all CI checks. The PR adds linter rules for type-check-only imports and implements deferred imports to optimize runtime performance. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged by maintainer upils. Added three linter rules to enforce conditional imports for type-only dependencies, resolved associated lint errors, and implemented deferred type checking to experiment with reducing runtime import overhead. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #797 perf: add TC001/2/3 linter rules to check imports | craft-application | merged | Merged after approval. Introduces TC001/2/3 linter rules to validate imports and resolves associated errors across 29 files. Core CI checks passed. Implements gradual improvements to import handling precision. |