Exploring Pyright

po5i profile image Carlos Villavicencio ・1 min read

Are you using Python type annotations? Having fun with mypy? Microsoft created some years ago yet another static type checker called Pyright.

GitHub logo microsoft / pyright

Static type checker for Python


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.

Type Checking Features

  • PEP 484 type hints including generics
  • PEP 526 syntax for variable annotations
  • PEP 544 structural subtyping
  • PEP 561 distributing and packaging type information
  • PEP 563 postponed evaluation of annotations
  • PEP 585 type hinting generics in standard collections
  • PEP 589 typed dictionaries
  • PEP 591 final qualifier
  • PEP 593 flexible variable annotations
  • PEP 604 complementary syntax for unions
  • PEP 612 parameter specification variables
  • PEP 613 explicit type aliases
  • Type inference for function return values, instance variables, class variables…

Some devs said it has a very great speed compared to mypy. I haven't used for any of my project's CI pipeline yet but I have this VSCode extension which, if you use this editor for your Python projects, you will be grateful on how it catches bugs caused by typing issues. So far it catches more issues than mypy and its messages are somehow clearer.

Being both VSCode and Pyright built with JavaScript (yes, Pyright was written in JS), their integration is pretty sweet. Although you can integrate to your favorite editor (vim, emacs, etc...).

The CLI is pretty similar to mypy. I'd suggest to give it a try and let me know how was your experience using it.

Wanna know how to start using type annotations in Python? Check out my tutorial published by Stack Builders.

Posted on by:

po5i profile

Carlos Villavicencio


Software development enthusiast. I am constantly learning and growing. I love supporting and building communities. Outside the programming world, I'm an amateur photographer and martial artist.


Editor guide