Pytype is a static analysis tool that derives types from your Python code without the need for type annotations. However, it can also enforce type annotations that are in the code. Although annotations are optional for Pytype, they are checked and applied if they are present. The type annotations generated by Pytype are stored in standalone .pyi files, which can be merged back into Python using merge-pyi. Finally, it flags common errors such as misspelled attribute names or function calls and much more, even across file boundaries.


  • All common Linux distributions are supported

  • macOS ≥ 10.7 and Xcode ≥ 8

  • Windows with WSL. In addition, the following libraries must be installed:

    $ sudo apt install build-essential python3-dev libpython3-dev


Pytype can be easily installed with

$ pipenv install pytype

The installation can then be checked with

$ pipenv run pytype file_or_directory


For a Python package, you can set up Pytype by creating a pytype.cfg file with

$ pipenv run pytype --generate-config pytype.cfg

This then starts with for example

# NOTE: All relative paths are relative to the location of this file.


# Space-separated list of files or directories to exclude.
exclude =

# Space-separated list of files or directories to process.
inputs =

Now you can customise the configuration file according to your requirements.

Additional scripts#


in-progress type annotator for ASTs


Merge type information from a .pyi file into a Python file


parser for .pyi files


debugging tool for pytype developers that analyses a single python file assuming that .pyi files have already been generated for all dependencies


cross-references generator