11.05.2018       Выпуск 229 (07.05.2018 - 13.05.2018)       Статьи

Pyre - модуль проверки типов для Python


Экспериментальная функция:

Ниже вы видите текст статьи по ссылке. По нему можно быстро понять ссылка достойна прочтения или нет

Просим обратить внимание, что текст по ссылке и здесь может не совпадать.

Today, we're excited to announce Pyre, a static type checker for Python. Pyre is designed to help improve the quality and development speed in large Python codebases by flagging type errors interactively in your favorite editor. It checks the gradual type annotations that are already part of the Python programming language (



The goal for Pyre is to allow you to write readable, idiomatic Python without getting in your way:

  1. Pyre is designed to be highly parallel, optimizing for near-instant responses so that you get immediate feedback, even in a large codebase.
  2. By design, type annotations are not required everywhere. If you're not fully committed to static typing, or if you have an existing codebase that you intend to convert gradually over time, you can still get useful results.


At Facebook and Instagram, we use Python extensively. We love its expressiveness, flexibility, and developer productivity. Traditionally, some of these benefits have faded when maintaining a very large product codebase (millions of lines). There are a couple of challenges:

  • The lack of static guarantees can make it harder to safely make changes to an existing codebase, making the code more error-prone and actually slowing down development relative to statically typed code.
  • It is challenging to build high-quality tools like code search, autocomplete, navigation, and refactoring support; lacking tools like these is especially detrimental when working in a large codebase.

To address these issues, we've built Pyre to be both a fast PEP 484-compliant type checker, and a great platform for building deeper static analysis tools.

The Type Checker

Pyre is designed with

interactive performance

in mind; the goal is to get you any relevant type errors as soon as possible. To achieve this, it runs as a server that continually updates its understanding of your code in memory. It uses


to spot changes to your code (i.e. Pyre is notified as soon as you hit 'save' in your favorite editor).

Pyre maintains a dependency graph representation of your code. When your code changes, Pyre will re-analyze


the code that has changed and its direct dependencies, updating the dependency graph as needed along the way. Results are available from the command-line, as structured JSON, or through integration with VSCode and Nuclide. Beyond type checking, Pyre supports a number of features, such as automatic re-checking of edited files, through the

Language Server Protocol


Internally, Pyre's high-level architecture is similar to that of


, Facebook's type checker for PHP. Like the Hack type checker, Pyre is implemented in OCaml and uses a lock-free shared memory datastructure to achieve parallelism.


Pyre is designed for code written in Python 3 and currently supports the majority of features ('types of types') defined in PEP484. We aim to be compatible with


, the de facto reference implementation for Python type checking, though minor implementation differences are possible. We are committed to supporting Python type checking as the language evolves.


Shipping Pyre would not have been possible without the help of our contributors and early adopters within Facebook and Instagram.

Contributors: Jonathan DiLorenzo; Zoe Hu; Rijnard van Tonder The Python Foundation team: Łukasz Langa; Jason Fried The Instagram Core Server team: Carl Meyer Early Adopters: Zsolt Dollenstein; Hasnain Lakhani; Till Varoquaux; and others.

Written by: Sinan Cepel, Software Engineer Dominik Gabi, Software Engineer Marco Leogrande, Software Engineer, Shannon Zhu, Software Engineer, Pieter Hooimeijer, Engineering Manager

Лучшая Python рассылка

Разместим вашу рекламу

Пиши: mail@pythondigest.ru

Нашли опечатку?

Выделите фрагмент и отправьте нажатием Ctrl+Enter.

Система Orphus