Recommended Open source
Use Pyright to check Python types
Add type hints to Python code and check them with Pyright in strict mode for new code.
Cost
Open source. MIT licence, free to use in any project. Pylance, its editor extension, is not open source.
How to do it
Pyright 1.0 shipped in March 2019, and 1.1.414 came out in September 2026. PyPI counted over 11 million downloads of its wrapper in the week to 18 October 2026. It is MIT licensed and maintained by Microsoft. Choose something else when a framework needs a type plugin. mypy runs plugins for Django and Pydantic, but its 1.0 shipped only in February 2023. Run it on every change, as Use strict types and linters says.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
TOML example
# pyproject.toml
[tool.pyright]
include = ["src"]
typeCheckingMode = "strict"
pythonVersion = "3.13"
Python example
from dataclasses import dataclass
@dataclass(frozen=True)
class OrderLine:
price: int
qty: int
def total(lines: list[OrderLine]) -> int:
return sum(line.price * line.qty for line in lines)
How to check
pyright exits 0 in the build, and pyproject.toml sets typeCheckingMode = "strict" for every new package.
Sources
Related rules
- Use Python for data work and as a second server language in Software choices
- Use strict types and linters in AI development
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/testing-and-code-quality/pyright. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.