mypy
mypy brings static type checking to Python through gradual adoption of type hints, letting you add type safety incrementally without rewriting existing code. It supports strict mode for maximum safety, works seamlessly with FastAPI and Django, and uses type inference to minimize annotation overhead.
mypy adds static type checking to Python projects through gradual typing and type hints, catching errors before runtime.
AI-generated summary based on this skill's SKILL.md
Install
bobmatnyc/claude-mpm-skills/mypy · repository language: Python
git clone https://github.com/bobmatnyc/claude-mpm-skills
cp -r claude-mpm-skills/toolchains/python/tooling/mypy ~/.claude/skills/mypynpx skillfed install bobmatnyc/claude-mpm-skills/mypyFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is mypy and how does static type checking python work?
mypy is a static type checker for Python that analyzes your code before runtime to catch type errors. It brings static type checking to Python through gradual adoption of type hints, letting you add type safety incrementally without rewriting existing code. mypy uses type inference to minimize annotation overhead while supporting strict mode for maximum safety.
How can mypy catch type errors before runtime in FastAPI and Django?
mypy catches type errors before runtime in FastAPI and Django applications by analyzing function signatures, variable assignments, and API endpoint definitions against their declared types. When you annotate your route handlers, request models, and database queries with type hints, mypy validates that arguments match expected types and return values conform to contracts, preventing runtime failures in production.
How do I configure and enforce strict type checking in CI/CD pipelines?
mypy can be configured with strict mode settings in a mypy.ini or pyproject.toml file, then integrated into your CI/CD pipeline as a build step. Set options like `strict = True`, `disallow_untyped_defs`, and `disallow_incomplete_defs` to enforce comprehensive type coverage. Run mypy in your pipeline before tests or deployment to block code that fails type validation.
What type annotations, generics, and advanced typing patterns does mypy support?
mypy supports Python type annotations including Optional, Union, List, Dict, and custom types. It handles generics through TypeVar for parameterized types, Protocol for structural typing, and advanced patterns like bounded TypeVars, type aliases, and overloads. mypy also supports type stubs for untyped libraries and can infer types automatically when explicit annotations aren't provided.
How can I integrate mypy with my IDE and development workflow?
mypy integrates with most IDEs through plugins and language servers. Many editors like VS Code, PyCharm, and Vim can run mypy in real-time as you type, showing type errors immediately. Configure mypy in your project's configuration file, then enable the mypy plugin in your IDE settings to get instant feedback on type violations during development.
What's the difference between mypy and other python type checking tools?
mypy is the original and most widely-adopted Python type checker, supporting gradual typing and extensive configuration options. Other tools like Pyright offer different trade-offs in speed and strictness. mypy's strength lies in its mature ecosystem, broad library support through type stubs, and flexibility for incremental adoption across large codebases.
SKILL.md
rendered from the published skill — quoted content, verbatim
mypy - Static Type Checking for Python
Overview
mypy is the standard static type checker for Python, enabling gradual typing with type hints (PEP 484) and comprehensive type safety. It catches type errors before runtime, improves code documentation, and enhances IDE support while maintaining Python's dynamic nature through
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 2 files
toolchains/python/tooling/mypy/SKILL.md
toolchains/python/tooling/mypy/metadata.json