Microsoft’s Pyright runs independently of Python, intended to give it a performance boost over rivals such as Mypy – but it remains a work in progress
Microsoft has released Pyright, an open-source static type-checking tool for the Python programming language that it claims runs faster than other popular type-checkers such as Mypy.
Microsoft said the tool also runs faster than its own Python Language Server, which offers some overlapping features.
Pyright is written in Typescript and runs on Node.js, meaning it doesn’t require an existing Python runtime or imported third-party packages.
It’s intended for large Python source bases, and can be set up to perform fast incremental updates when files are modified.
The tool supports flexible configuration, providing granular control over settings.
Users can set up different execution environments for different subsets of a source base, each of which can use different module search paths, Python language versions and target platforms.
Pyright supports features such as type hints, variable notation and structural subtyping.
It can be used as a Language Server Protocol plugin for Microsoft’s Visual Server Code source-code editor or can be run as a stand-alone command-line tool, Microsoft said.
It said Pyright typically runs five times faster than Python type checkers that are themselves written in Python, such as Mypy, Pytype and Pyre, whose speed is limited by that of Python itself.
Microsoft said some of Pyright’s features overlap with the Python Language Server offering, with the difference that Pyright is entirely focused on type checking, enabling it to offer more configurability, command-line execution and better performance.
Python 3.0 support
The tool is open source, with its code hosted on GitHub, and Microsoft provided a to-do list of unfinished features.
But it said only Python 3.0 and newer are supported, with no plans to support older versions.
The move was a landmark shift for the company, which at one point had tried to discredit open source by characterising it as a “cancer”.