Yesterday, Microsoft released a new static type checker for Python called Pyright to fill in the gaps in existing Python type checkers like mypy. Currently, this type checker supports Python 3.0 and its newer versions.
What are the type checking features Pyright brings in?
- It comes with support for PEP 484 (type hints including generics), PEP 526 (syntax for variable annotations), and PEP 544 (structural subtyping).
- It supports type inference for function return values, instance variables, class variables, and globals.
- It provides smart type constraints that can understand conditional code flow constructs like if/else statements.
Pyright shows 5x speed as compared to mypy and other existing type checkers written in Python. It was built keeping large source bases in mind and can perform incremental updates when files are modified.
No need for setting up a Python Environment
Since Pyright is written in TypeScript and runs within Node, you do not need to set up a Python environment or import third-party packages for installation. This proves really helpful when using the VS Code editor, which has Node as its extension runtime.
Pyright enables users to have granular control over settings. You can specify different execution environments for different subsets of a source base. For each environment, you can specify different PYTHONPATH settings, Python version, and platform target.
To know more in detail about Pyright, check out its GitHub repository.
Debugging and Profiling Python Scripts [Tutorial]
Python 3.8 alpha 2 is now available for testing
Core CPython developer unveils a new project that can analyze his phone’s ‘silent connections’