Type Hints for ML Code
Apply appropriate type hints for ML/PyTorch code. Use when adding type annotations to ML code or addressing mypy errors.
npx skills add majiayu000/claude-skill-registry --skill ml-type-hints-apassuello-multimodal-insight-e --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Type Hints for ML Code - Constitutional AI ## When to Apply Automatically activate when: - Adding type hints to ML code - Addressing mypy type errors - Working with PyTorch tensors, models, or optimizers - Dealing with HuggingFace transformers types ## Project Type Checking Status **Current mypy status:** - **41 errors remaining** (documented in MYPY_ANALYSIS_REPORT.md) - **Status**: Accepted as reasonable for ML research code - **CI behavior**: `continue-on-error: true` (doesn't fail builds) **Key insight**: Perfect type coverage is not the goal for ML code. Prioritize correctness and readability over type perfection. ## When to Use Type Hints ### ✅ Do Use Type Hints For 1. **Public API functions** ```python def load_model(model_name: str) -> tuple[AutoModelForCausalLM, AutoTokenizer]: """Load model and tokenizer.""" pass ``` 2. **Configuration dataclasses** ```python @dataclass class TrainingConfig: learning_rate: float batch_size: int num_epochs: int ``` 3. **Clear input/output types** ```python def evaluate_text(text: str, framework: ConstitutionalFramework) -> dict[str, Any]: """Evaluate text against principles.""" pass ``` 4. **Helper functions with simple types** ```python
- When to Apply
- Project Type Checking Status
- When to Use Type Hints
- ✅ Do Use Type Hints For
- ❌ Don't Force Type Hints For
- PyTorch Type Patterns
- Tensor Types
- Model and Optimizer Types
- Device Types
- Handling "Any" Type
- When Any is Acceptable
- Prefer Specific Types When Possible
- Optional and Union Types
- Common ML Type Patterns
Run mypy on all source code mypy constitutional_ai/ --ignore-missing-imports Run on specific module mypy constitutional_ai/framework.py Show error codes (useful for targeted ignores) mypy constitutional_ai/ --show-error-codes Strict mode (educational, will fail) mypy constitutional_ai/ --strict
What does the Type Hints for ML Code skill do?
Apply appropriate type hints for ML/PyTorch code. Use when adding type annotations to ML code or addressing mypy errors.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill ml-type-hints-apassuello-multimodal-insight-e --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
