Static type checker for Python
Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fast incremental updates when files are modified.
Pyright supports configuration files that provide granular control over settings. Different “execution environments” can be associated with subdirectories within a source base. Each environment can specify different module search paths, python language versions, and platform targets.
Pyright ships as both a command-line tool and a VS Code extension that provides many powerful features that help improve programming efficiency.
The VS Code extension supports many time-saving language features including:
Pyright includes a recent copy of the stdlib type stubs from Typeshed. It can be configured to use another (perhaps more recent or modified) copy of the Typeshed type stubs. Of course, it also works with custom type stub files that are part of your project.
For rich Python editing and debugging capabilities with Visual Studio Code, be sure to also install the official Microsoft Python extension for Visual Studio Code as Pyright only provides syntax and type checking.
For most VS Code users, we recommend using the Pylance extension rather than Pyright. Pylance incorporates the pyright type checker but features additional capabilities such as IntelliCode and semantic token highlighting. You can install the latest-published version of the Pylance VS Code extension directly from VS Code. Simply open the extensions panel and search for
For vim/neovim users, you can install coc-pyright, the Pyright extension for coc.nvim.
Alternatively, ALE will automatically check your code with Pyright, without requiring any additional configuration.
The latest version of the command-line tool can be installed with npm, which is part of node. If you don't have a recent version of node on your system, install that first from nodejs.org.
To install pyright globally:
npm install -g pyright
On MacOS or Linux, sudo is required to install globally:
sudo npm install -g pyright
Once installed, you can run the tool from the command line as follows:
To update to the latest version:
sudo npm update -g pyright
Pyright’s type-checking functionality and language features are now incorporated into a VS Code extension called Pylance, the officially supported Python Language Server from Microsoft. Pylance is designed to work with the Python extension for VS Code. In addition to Pyright’s functionality, Pylance adds compatibility with several advanced features including IntelliCode for AI-assisted completions. If you are a VS Code user, we recommend that you uninstall Pyright and instead install Pylance. You will get all the benefits of Pyright and more!
Installing both Pyright and Pylance at the same time is not recommended. If both are installed and enabled, you will see duplicate errors, hover text, and completion suggestions.
Pyright provides support for Python 3.0 and newer. There is currently no plan to support older versions.
Do you have questions about Pyright or Python type annotations in general? Post your questions in this gitter channel.
Q: What is the difference between Pyright and Pylance?
A: Pyright is an open-source Python type checker and language server. Pylance leverages Pyright’s functionality with additional features, some of which are not open-sourced.
Q: What is the long-term plan for Pyright?
A: Pyright is now an officially-supported Microsoft type checker for Python. It will continue to be developed and maintained as an open-source project under its original MIT license terms. The Pyright extension for VSCode is a reference implementation and is not guaranteed to be fully functional or maintained long-term.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.