Static type checker for Python
open sourceMITfree
Pyright is a full-featured, standards-based static type checker for Python from Microsoft, designed for high performance on large codebases. It implements the typing PEPs from type hints and generics to structural subtyping, typed dictionaries, variadic generics, dataclass transforms and the new type parameter syntax, infers types for return values and variables, and narrows types through if/else control flow. It runs as a command-line tool with a watch mode that updates incrementally, and as a language server: its own VS Code extension, Neovim, Sublime Text, Emacs and PyCharm integrations, and Microsoft's Pylance extension, which builds on it. Configuration files give subdirectories their own execution environments with different search paths, Python versions and platforms.
Problems it solves
- type check a large Python codebase quickly
- get type errors in my editor as I type Python, with a language server
- catch Python bugs from wrong types in CI before they ship
- type check Python with the newest typing PEPs supported early
- use different Python versions and search paths for different folders of one repo when type checking
- a faster alternative to mypy for strict Python type checking
- Python type checking in Neovim, Emacs or Sublime Text
Features
- standards-based type checking of the typing PEPs
- type inference for return values and variables
- control-flow type narrowing
- watch mode with fast incremental updates
- language server for editors
- VS Code extension
- configuration files with per-directory execution environments
- browser playground
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what Pyright does.
- ty An extremely fast Python type checker and language server, written in Rust
- Pylance A performant, feature-rich language server for Python in VS Code
- mypy Optional static typing for Python
- Sorbet A fast, powerful type checker designed for Ruby
- TypeScript JavaScript with static types, compiled to plain JavaScript
- Flow A static type checker and typed dialect of JavaScript
