Static type checker for Python
Go to file
2019-04-13 01:32:31 -07:00
.github/ISSUE_TEMPLATE Update issue templates 2019-03-31 08:01:46 -07:00
.vscode Improved console messages for command-line. 2019-04-06 14:09:18 -07:00
client Published 1.0.12. 2019-04-13 01:32:31 -07:00
docs Added proper handling of class decorators. 2019-04-12 23:51:22 -07:00
server Published 1.0.12. 2019-04-13 01:32:31 -07:00
.gitignore Updated build scripts to build command-line version into an npm module. 2019-03-24 02:58:01 -07:00
.npmignore Updated build scripts to build command-line version into an npm module. 2019-03-24 02:58:01 -07:00
CONTRIBUTING.md Updated LICENSE and CONTRIBUTING files. 2019-03-17 22:05:33 -07:00
index.debug.js Fixed debugging of command-line tool. 2019-03-26 23:53:50 -07:00
index.js Updated build scripts to build command-line version into an npm module. 2019-03-24 02:58:01 -07:00
LICENSE.txt Updated LICENSE and CONTRIBUTING files. 2019-03-17 22:05:33 -07:00
package-lock.json Published 1.0.12. 2019-04-13 01:32:31 -07:00
package.json Published 1.0.12. 2019-04-13 01:32:31 -07:00
README.md Implemented type checks for property setters and deleters. 2019-04-13 01:25:56 -07:00

Pyright

Static type checker for Python

Speed

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.

No Dependency on Python Environment

Pyright does not require a Python environment or imported third-party packages to be installed.

Configurability

Pyright supports configuration files that provide granular control over settings. Different “execution environments” can be associated subdirectories within a source base. Each environment can specify different module search paths, python language versions, and platform targets.

Type Checking Features

Pyright supports:

  • PEP 484 type hints including generics
  • PEP 526 syntax for variable annotations
  • PEP 544 structural subtyping
  • Type inference for function return values, instance variables, class variables, and globals
  • Smart type constraints that understand conditional code flow constructs like if/else statements

Built-in Type Stubs

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.

Command-line Tool or Visual Studio Code Extension

Pyright includes both a command-line tool and an extension for Visual Studio Code that implements the Language Server Protocol.

For rich Python editing and debugging cabailities 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.

Documentation

Limitations

Pyright currently provides support for Python 3.0 and newer. There is currently no plan to support older versions.

Pyright is a work in progress. Type-checking capabilities are not fully implemented. For a list of incomplete functionality, refer to the TODO list below.

FAQ

Q: What is the difference between pyright and the Microsoft Python Visual Studio Code plugin?

A: Pyright is focused on type checking. The Python VS Code plugin is Microsofts officially-supported extension for VS Code and provides a diverse array of features including auto-complete, debugging, linter plugins, type-checking plugins, and much more. Pyright can be used alongide the Microsoft Python extension.

Q: What is the difference between Pyright and the Microsoft Python Language Server?

A: The Microsoft Python Language Server is a language server protocol (LSP) implementation that works with the Microsoft Python VS Code plugin. It is officially supported by a team of Microsoft engineers. It focuses on providing core editing capabilities such as auto-completion, code navigation and documentation. Pyright is focused on providing fast syntax and type checking with features such as more configurabilty and command-line execution.

Q: What is the long-term plan for Pyright?

A: Pyright is a side project with no dedicated team. There is no guarantee of continued development on the project. If you find it useful, feel free to use it and contribute to the code base.

Installation

You can install the latest-published version of the Pyright VS Code extension directly from VS Code. Simply open the extensions panel and search for pyright.

The latest version of the command-line tool can be installed with npm. To install it 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: pyright <options>

To update to the latest version: sudo npm update -g pyright

TODO

Pyright is a work in progress. The following functionality is not yet finished. If you would like to contribute to any of these areas, contact the maintainers of the repo.

  • Type analysis support for coroutines
  • Address the many TODO comments in the code
  • Provide switch that treats instance variables and methods that begin with underscore as private
  • Synthesize TypeVar param and return types for lambdas where possible
  • Validate that overridden methods in subclass have same signature as base class methods
  • Add support for type hints on var-arg parameters
  • Add support for NoReturn type
  • Add support for f-strings
  • Provide switch that reports circular import dependencies
  • Add numeric codes to diagnostics and a configuration mechanism for disabling errors by code

Contributing

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.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.