Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Microsoft introduces Pyright, a static type checker for the Python language written in TypeScript

Save for later
  • 2 min read
  • 25 Mar 2019

article-image

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.
  • Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at $19.99/month. Cancel anytime

Increased speed


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.

Flexible configurability


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’