Pyright Guide: Installation, Configuration, and Usage Conditions

Ever wanted to look for a faster version of Python without slowing down your workflow? Tools like MyPy can catch type errors, but they often feel slow or disconnected from the programmer’s experience. This is where Pyright comes in. Pyright is a Python standards-based static type checker designed for speed and fast response. It works both as a command-line tool and as a language server, allowing real-time diagnostics while writing code. It integrates closely with Microsoft’s Python tooling and works with all programmers via the Language Server Protocol (LSP).
What is Pyright?
Pyright uses a project-based configuration system that defines which files are analyzed and how imports are resolved. It also allows teams to specify the target Python version and control the level of strictness of type checking. This flexibility makes it easy to start with basic checks and gradually introduce more stringent rules as the codebase grows. Pyright integrates well with workflows and CI metrics effectively for large projects, allowing teams to use static typing without disrupting existing development processes.
If you want to know the basics of Python for building AI Agents, then check out our FREE course on ABC for building agent coding.
Purpose and key features
Pyright helps developers catch type errors early in Python code. Because Python’s typing is always optional at runtime, static analysis helps identify problems before execution, such as invalid, unsafe argument types. None access, and invalid assignments. Pyright follows Python’s typing standards and delivers fast response even for large code bases.
Pyright analyzes code using a project-wide engine that parses, compiles, and checks the type of files under configurable rules. It also integrates with programmers through a language server, enabling real-time diagnostics during development.
Key features include:
- Analysis of the entire project: Files processed, bound, and type-checked throughout the project.
- Flow-sensitive typing: Types are reduced based on control flow.
- Language server support: Provides real-time diagnostics to programmers.
- Type a completeness check: Helps verify the type of information libraries.
- Cross-editor portability: Used in TypeScript for consistent tooling support.
Also Read: Complete Python Tutorial for Learning Data Science from Scratch
Includes Pyright
Pyright is available as a command line tool and as a language server. The CLI is used for CI and local checks. A language server is used by programmers through the Language Server Protocol. Both use the same core engine.
The most common installation method is npm. A typical setup looks like this:
npm install -g pyright
pyright --versionYou can then run a type test with:
{
"include": ["."],
"exclude": ["**/__pycache__", "**/.venv", "**/.git"],
"typeCheckingMode": "basic",
"pythonVersion": "3.12"
}To start the language server directly, use:
pyright-langserver --stdio Community Python wrappers are also available. This installs Node and the Pyright npm package by default. They don’t change the check itself.
In Visual Studio Codedevelopers often use Pyright by using Pylancewhich uses Pyright under the hood. You can control the type checking behavior by using the workspace settings like python.analysis.typeCheckingMode again python.analysis.diagnosticMode. If you prefer to use Pyright directly, you can enter an exception An extension of Pyright.
In Neovimdevelopers usually use Pyright with a language server. Multiple settings are used nvim-lspconfig to stop it. Neovim starts the server with pyright-langserverand you can define the analysis settings below settings.python.analysis controlling the intensity and width of the work area.
Other LSP Customers
Pyright works for many editors because it acts as a language server. Any editor that supports the Language Server Protocol (LSP) it can start pyright-langserver. The server learns configuration from pyrightconfig.json or i tool.pyright section on pyproject.tomlwhich keeps type checking behavior consistent across different tools.
Editors like Emacs again Higher Text connect directly to pyright-langserver and manage tasks such as local discovery and server startup. Pyright itself does all kinds of testing and diagnostics.
Important features:
- Works with any LSP compliant scheduler
- It uses
pyright-langserveras a backend - Respect project configuration files
- It provides consistent diagnosis for all editors
Configuration via pyrightconfig.json
Pyright offers two main ways to define a project configuration. You can put a pyrightconfig.json file in the project root or define a tool.pyright part inside pyproject.toml. If both exist, pyrightconfig.json takes precedence.
Configuration focuses on several key aspects of how Pyright analyzes a project.
Files to be analyzed
- It is managed by
include,excludeagainignore - The files are listed
excludethey can still be analyzed when imported - The files are listed
ignorepress diagnostics
Python is natural
- Explained by
pythonVersionagainpythonPlatform executionEnvironmentsallows multiple targets- An import adjustment can be used
extraPathsagainvenvsettings
The intensity of the type test
typeCheckingModedefines the base level- Strict rules can be enabled for specific files or folders
Diagnostic configuration
- The rules for each report can be customized
- Difficulty levels can be
none,info,warningorerror
Examples of Common Project Types
The following examples show a typical Pyright setup. They have their own ideas but they work. Each uses written options. The goal is to measure signal, performance, and reception speed.
Single file script or notebook style repo
This setup favors fast response. Avoids premature hardening. It works well for testing with small tools.
- A wide range includes to catch obvious issues
- Basic evaluation of low friction
- The plain Python version
Repo package with src/ build and tests
This setting stabilizes the import. It shows how the package is actually used. It is common in libraries and churches.
- Separate
srcagaintestsreferences - Use a standard type test
- Prepare
executionEnvironmentsto solve import methods correctly
{
"include": ["src", "tests"],
"exclude": ["**/__pycache__", "**/.venv", ".tox", "dist", "build"],
"typeCheckingMode": "standard",
"pythonVersion": "3.12",
"executionEnvironments": [
{
"root": "src",
"extraPaths": ["src"]
}
]
}This setup supports scaling. It lays down the rules. It allows for robust incremental discovery of each package.
- Shared base configuration
- Each package emits
- Only strict testing of new code
Root config:
{
"exclude": ["**/__pycache__", "**/.venv", "**/.git", "**/node_modules"],
"pythonVersion": "3.12",
"typeCheckingMode": "standard",
"reportMissingImports": "error",
"reportMissingTypeStubs": "none"
}Package configuration:
{
"extends": "../../pyrightconfig.base.json",
"include": ["src", "tests"],
"strict": ["src/new_code"],
"executionEnvironments": [
{ "root": "src", "extraPaths": ["src"] }
]
}A Django app
This setting reduces noise. Avoids generated files. It keeps missing types visible but does not block them.
- Do not include moving and static files
- Beware of stray stubs
- Custom stub index
{
"include": ["."],
"exclude": [
"**/__pycache__",
"**/.venv",
"**/migrations/**",
"static",
"media"
],
"typeCheckingMode": "standard",
"reportMissingTypeStubs": "warning",
"stubPath": "typings"
}FastAPI service
This setup includes strong typing. It highlights the unknown without breaking structures.
- Standard inspection
- Beware of unknown brands
- Fits well with dynamic frameworks
{
"include": ["app", "tests"],
"exclude": ["**/__pycache__", "**/.venv"],
"typeCheckingMode": "standard",
"reportUnknownParameterType": "warning",
"reportUnknownVariableType": "warning"
}These patterns are the starting points. They are designed to be flexible. Pyrite works best when the intensity is gradually increased.
When can you choose Pyrright?
The situation
Why Choose Pyright
A very fast type test
Pyright is optimized for performance and delivers fast results even for large projects.
Responsive editor’s response
It performs incremental analysis, so errors appear quickly while typing.
Consistent results in editor and CI
The CLI and the language server use the same key parser, keeping diagnostics the same in all environments.
Gradual adoption of strong typing
Teams can start with basic checks and tighten rules as the codebase changes.
Large codebases
Project-based configuration and measurement of well-planned analysis across multiple files.
Visual Studio Code with Pylance
Pylance runs on Pyright and provides rich, real-time diagnostics and diagnostics.
It works in many editors
Editors such as Neovim, Emacs, and Sublime Text can use Pyright with the Language Server Protocol.
Modern Python typing support
Pyright closely follows the official typing standard and supports advanced abbreviations and generics.
Performance oriented teams
Teams that value fast response and predictable behavior across tools benefit the most.
Also read: Basics of Python Programming for Beginners
The conclusion
Pyright provides a fast, standards-based approach to static type checking in Python. It combines robust analysis with the integration of a responsive editor and a flexible project configuration system. From small repositories to large monorepos, it adapts to different team needs and intensity levels. Its language server architecture delivers consistent diagnostics across all compilers and CI environments. With clear configuration options and gradual adoption methods, teams can introduce robust typing without disrupting existing workflows. For developers who value performance, scalability, and modern typing support, Pyright provides an efficient foundation for building safer and more maintainable Python code.
Sign in to continue reading and enjoy content curated by experts.



