---
title: "Use Pyright to check Python types · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/testing-and-code-quality/pyright
updated: 2026-10-21
licence: "All rights reserved"
---

# Use Pyright to check Python types

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [Testing and code quality](https://agentwranglers.se/playbook/stack/testing-and-code-quality)
- Rule: 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: 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](https://agentwranglers.se/playbook/ai-assisted-development/rules-the-agent-cannot-break/strict-tooling) says.
- Check: `pyright` exits 0 in the build, and `pyproject.toml` sets `typeCheckingMode = "strict"` for every new package.

## 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

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

### Python example

```python
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)
```

## Sources

- [Pyright](https://microsoft.github.io/pyright/)

## Related rules

- [Use Python for data work and as a second server language](https://agentwranglers.se/playbook/stack/languages-and-runtimes/python) in Software choices
- [Use strict types and linters](https://agentwranglers.se/playbook/ai-assisted-development/rules-the-agent-cannot-break/strict-tooling) in AI development

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

- Previous: [Use TypeScript in strict mode](https://agentwranglers.se/playbook/stack/testing-and-code-quality/typescript-strict)
- Next: [Use Renovate for dependency updates](https://agentwranglers.se/playbook/stack/testing-and-code-quality/dependency-bot)
- [Testing and code quality](https://agentwranglers.se/playbook/stack/testing-and-code-quality)
