gpsaggese/helpers / .claude/skills/coding.fix_bloated_imports
coding.fix_bloated_imports
VerifiedFix Python imports of large packages needed only for few functions in a module
-
I pass you one or more files
<FILES>and one or more packages<PACKAGES>that are large to import (e.g.,ipython,pandas) and needed in only a few functions -
In
<FILES>, use a conditional import for type checking and lazy imports for<PACKAGES>- E.g., transform
intodef make_slider() -> "ipywidgets.IntSlider": import ipywidgets ...from typing import TYPE_CHECKING if TYPE_CHECKING: import ipywidgets def make_slider() -> "ipywidgets.IntSlider": import ipywidgets ...
- E.g., transform
-
Use forward references only for the package types, not for the whole expression
- Bad (quotes the whole expression as one string)
"Tuple[Union[ipywidgets.FloatSlider, ipywidgets.IntSlider], ipywidgets.HBox]" - Good (quotes only the package types)
Tuple[Union["ipywidgets.FloatSlider", "ipywidgets.IntSlider"], "ipywidgets.HBox"]
- Bad (quotes the whole expression as one string)
-
If most functions in
<FILES>need<PACKAGES>, suggest not doing this transform
Verification
- Confirm
<PACKAGES>is imported only underTYPE_CHECKINGor inside the functions that use it - Confirm forward references quote only the package types, not full expressions
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |