Agent Wranglers

STK-46Default 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.

Review by

2027-04-30

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

TOML example

# pyproject.toml
[tool.pyright]
include = ["src"]
typeCheckingMode = "strict"
pythonVersion = "3.14"

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

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/testing-and-code-quality/pyright">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.