python-type-system

Enforce Python type safety with mypy, Protocols, TypedDict, and Generics.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill python-type-system
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-type-system
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-python/skills/python-type-system
Command: npx skills add https://github.com/TheBushidoCollective/han --skill python-type-system

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill teaches Python's type system, including type hints, mypy, Protocols, TypedDict, and Generics.

Core Features & Use Cases

  • Static Checking: Detect type issues before runtime.
  • Advanced Typing: Protocols, TypedDict, and generics for robust APIs.
  • Tooling: How to configure mypy and type-check workflows.

Quick Start

Add type hints to a simple function and run mypy to validate types.

Frequently Asked Questions about python-type-system

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add type hints to Python code and check them with mypy?

Type hints annotate function parameters and return values with expected types. Install mypy via pip, add type annotations to your code (e.g., `def greet(name: str) -> str:`), then run `mypy your_file.py` to detect type mismatches before runtime.

What's the difference between type hints and runtime type checking in Python?

Type hints are static annotations that mypy analyzes without executing code, catching errors early. Python doesn't enforce type hints at runtime by default; mypy provides the checking layer that validates types match your annotations across modules.

When should I use TypedDict instead of regular dictionaries in Python?

TypedDict enforces a fixed structure and specific key types for dictionaries, enabling mypy to catch missing or incorrectly typed keys. Use it when you pass dictionaries between functions and need static verification of their shape and contents.

How do I configure mypy for a Python project?

Configure mypy by creating a `mypy.ini` or adding `[tool.mypy]` section to `pyproject.toml` with settings like `strict = True` for strictness level, `ignore_missing_imports` for untyped dependencies, and `exclude` patterns. Run `mypy` to validate your entire project against these rules.

What are Protocols and when do I need them for type-safe Python?

Protocols define structural interfaces without explicit inheritance—an object matches if it has the required methods and attributes. Use Protocols for flexible, type-safe APIs where you care about behavior, not class identity, enabling duck typing with static verification.

Can I use modern Python syntax like built-in generics with mypy?

Yes, mypy supports PEP 604 union syntax (`int | str`) and built-in generic types (`list[int]`, `dict[str, int]`) in Python 3.10+. Configure mypy to recognize your Python version in `pyproject.toml` or `mypy.ini` to enable modern typing syntax validation.