Type Checking
The handbook recommends Pyrefly (Meta) as the default type checker for new Python projects. mypy remains the established option, ty is Astral’s fast beta alternative, and pyright rounds out the field. These pages explain how each checker works, when to choose which, and how to adopt typing without rewriting your codebase.
Pick a type checker
Adopt type checking
More Type Checking pages
Everything else tagged type-checking, grouped by section. Pages featured above are not repeated here.
Tutorial
Build and Publish a Python Package with uv, Ruff, Pyrefly, pytest, and GitHub Actions
Build a Python library with uv, Ruff, Pyrefly, and pytest. Set up CI/CD with GitHub Actions. Publish to PyPI with trusted publishing.
Set up a complete Python project with uv, Ruff, Pyrefly, pytest, and pre-commit
Tutorial: build a Python project from scratch with uv, Ruff, Pyrefly, pytest, and pre-commit. Set up linting, type checking, and testing.
Set up type checking for a Python project with ty
Add ty to a uv project, read its diagnostics, and tune rule levels so type mistakes surface before the code ever runs.
How To
How to add type annotations to a Python project with pyrefly infer
Add type annotations to your Python project using pyrefly infer. Automatically generate parameter and return types from static code analysis.
How to configure Claude Code with a Python type checker
Integrate type checkers with Claude Code using CLAUDE.md, language-server plugins, Stop hooks, and pre-commit to surface errors during turns, not after.
How to configure mypy and django-stubs in a uv project
Set up django-stubs and mypy in uv projects: configure the Django mypy plugin in pyproject.toml for legacy codebase type checking.
How to configure VS Code for type checking in a uv project
Set up type checking in VS Code for uv projects using ty or mypy extensions, including daemon mode and workspace diagnostics.
How to enforce annotation coverage on a Python library with Pyrefly
Track what fraction of your library's public API has type annotations and enforce a minimum threshold in CI with pyrefly coverage check.
How to migrate from mypy to ty
Migrate from mypy to ty for 9x faster type checking. Includes config mapping, compatibility guide, and plugin alternatives.
How to migrate from pyright to ty
Migrate from pyright to ty. Get faster type checking with no Node.js dependency and significantly simpler CI.
How to set up pre-commit hooks for a Python project
Install and configure pre-commit to automatically run linters, formatters, and checks on Git commits. Includes Ruff, mypy, and ty integration.
How to ship type annotations with a Python library
Add a py.typed marker and verify it ships in your wheel so your users' type checkers can read your annotations.
How to test a Python library against multiple type checkers
Test your library against mypy, Pyright, and Pyrefly to catch type errors across all common checkers before release.
How to Type-Check a Django Project with Pyrefly
Type-check a Django project with Pyrefly: install django-stubs, run the checker, and suppress unresolved errors.
How to use ty in CI
Set up ty type checking in GitHub Actions, GitLab CI, and other CI platforms with the right output format for inline annotations.
Explanation
Does Ruff support type checking?
No. Ruff is a linter and formatter; it does not perform type inference. Use ty, mypy, Pyright, or Pyrefly alongside Ruff for type checking.
How do Ruff and Pylint compare?
Ruff outpaces Pylint by orders of magnitude with auto-fix support; Pylint adds semantic depth Ruff doesn't cover yet.
How mypy, ty, and Pyrefly handle untyped code
mypy skips unannotated code by default; ty and Pyrefly infer and check it. This creates friction when migrating from mypy to stricter checkers.
Complete Guide to ty
A comprehensive guide to ty, the fast Python type checker from OpenAI. Learn installation, configuration, editor setup, and migration from mypy or pyright.
What is a Python language server?
A long-running process providing editors with autocomplete, hover docs, go-to-definition, and diagnostics. How they relate to type checkers.
What is PEP 484?
PEP 484: Python's optional type hints standard. Add type annotations for IDE autocomplete and type checker verification.
What is PEP 561?
PEP 561 defines how packages ship type info: py.typed markers for inline annotations, -stubs packages for separate types.
What is PEP 604?
PEP 604 lets Python 3.10+ write union types with the pipe operator: int | str replaces Union[int, str], and int | None replaces Optional[int].
What is PEP 612?
PEP 612 adds ParamSpec and Concatenate to Python's typing system so decorators can preserve the signatures of the functions they wrap.
What is PEP 649?
PEP 649: Deferred type annotations in Python 3.14. Avoid runtime errors from forward references and complex types.
What is PEP 681?
PEP 681's dataclass_transform marker tells type checkers a library's classes behave like dataclasses, eliminating the need for per-library checker plugins.
What is PEP 688?
PEP 688 types the buffer protocol. Learn why type checkers now reject bytearray where bytes is expected.
What is PEP 695?
PEP 695 adds Python 3.12 syntax for generics: class Box[T], def first[T], and type aliases without TypeVar or Generic base classes.
Reference
basedpyright
Basedpyright: pyright fork with Pylance editor features, PyPI distribution, stricter diagnostic rules, and no Node.js dependency.
pylint
Pylint: static analyzer catching errors beyond style linters—duplicate code, cyclomatic complexity, design issues.
pyright
Fast Python type checker from Microsoft with strong error detection. Integrates with VS Code through Pylance for immediate feedback.
ty
ty is a Python type checker from Astral (OpenAI). Features, configuration, IDE integration, and comparison to mypy and Pyright.
zuban
Zuban: Rust type checker with mypy and pyright modes, from Jedi's author. Fast performance, AGPL-3.0 or commercial license.
From the blog
Posts tagged type-checking.
-
If you're on mypy in 2026, Pyrefly is the obvious upgrade
Pyrefly 1.0 (May 12, 2026) makes the mechanical half of a mypy migration free. `pyrefly init` reads `mypy.ini`, writes a Pyrefly config, and baseline files keep CI green while you triage the diagnostics Pyrefly's tighter inference surfaces.
-
mypy 2.0 picks parallelism over a rewrite
mypy 2.0 shipped May 6, 2026, with experimental parallel type checking via --num-workers. The release reports up to 5x faster checks with 8 workers, narrowing the gap to ty, Pyrefly, and Zuban without trading Python for Rust.
-
ty and pyrefly find different bugs
Running ty 0.0.32 and pyrefly 0.62.0 on Textualize/rich raised 49 errors from ty and 20 from pyrefly. The 2.5x gap mostly disappears once you account for how each tool handles `# type: ignore` comments. Each tool also catches real bugs the other misses.
-
Migrating from mypy to ty: Lessons from FastAPI
Sebastián Ramírez has adopted ty across FastAPI, Typer, SQLModel, and more. His incremental migration strategy reveals the practical realities of switching type checkers on mature codebases.
-
Seven Claude Code Skills for Python from the Creator of spaCy
Matthew Honnibal's Claude Code skills collection covers type annotations, error handling, property-based testing, and mutation testing.
-
ty is Built with AI
Charlie Marsh and Boris Cherny are building their Python tools with Claude Code, demonstrating AI-assisted open source development.
-
ty: Astral's New Python Type Checker Released
Astral releases ty, a Rust-based Python type checker that's 20x faster than mypy with advanced type narrowing and incremental checking.
-
Analysis of the New Wave of Python Type Checkers
Rob Hand compares three Rust-based Python type checkers: ty (Astral), pyrefly (Meta), and zuban, covering performance and tradeoffs.
-
Google Sunsets Pytype: The End of an Era for Python Type Checking
Google ends Pytype support after Python 3.12. The bytecode-based type checker couldn't keep up with modern typing and IDE requirements.
-
ty's Breakthrough: Why Incremental Analysis Matters for Python
Charlie Marsh explains ty's incremental analysis system that recomputes only affected code when files change, from file-level to function-level.
-
Comparison of the Two New Typecheckers
Comparing ty and Pyrefly, two new Rust-based Python type checkers demonstrated at PyCon 2025's Typing Summit.
-
Pyrefly: Meta's New Type Checker for Python
Meta releases Pyrefly, a Rust-based Python type checker with a new inference engine designed for large codebases.
-
Early Explorations of Astral's Red Knot Type Checker
Early benchmarks of Astral's Red Knot (now ty) type checker show 100x faster cold starts than mypy, built in Rust.
-
It's happening! A Python Type Checker from Astral
Astral announces a Rust-based Python type checker focused on performance and minimizing false positives on untyped code.
-
Effective Python Developer Tooling in December 2024
An opinionated guide to Python developer tooling covering uv, ruff, pytest, mypy, and principles for productive Python development.