PyCon 2016 in Portland, Or
hills next to breadcrumb illustration

Tuesday 11:30 a.m.–noon

Python Typology

Matthias Kramm

Audience level:
Intermediate
Category:
Best Practices & Patterns

Description

With PEP 484, Python now has a standard for adding type declarations to your programs. What checks these declarations, and how? I present one of the options, pytype, which Google has been working on for the last two years.

Abstract

PEP 3107 and 484 provide a standard for Python type declarations. Since Python is a dynamically typed language, converting existing programs to a (partially) typed version is a gradual process that requires the proper tooling. For the last two years, Google has been working on their own static analysis system that has now been open-sourced. It differs from existing solutions (like mypy) in that it will also provide deep type checking for programs that don't have type annotations yet. Additionally, it can convert untyped to typed Python source code. I'll cover the syntax of type annotations, what the various tools for generating them and checking them are, and then, in some detail, how to use pytype on programs that are untyped or typed.