Keep Those Ducks in (Type) Check!

How I Learned to Stop Worrying and Love the Type Checker

Francesco Pierfederici

Code Analysis Mind Bending Programming Python 3 Type-Hinting

See in schedule Download Slides

PEP 484 (building upon PEP 3107) introduced support for type hints. Type hints allow, among other things, third-party tools to check Python code for possible bugs due to unintentional type mismatches. They also serve as documentation for your functions and methods.

Understandably - or maybe surprisingly - there has been a growing interest in type hints within the Python community, especially in the last few year; even though, outside large code bases, type hints are still not that widely used.

At the same time and for many years, as Python programmers, we are used to "duct typing": focusing more on object functionality and interfaces than on their types.

Are these two approaches completely at odds with each other?

This extremely practical tutorial will teach you what type hints are and how you use them in your own code. We will focus on realistic examples and see how type hints can co-exist with Python dynamism and duck-typing. We will explore the ways in which type hints can make your code better and in some cases faster.

We will use Python 3.7 and strongly recommend that attendees install a reasonably recent version of Python 3 to make the most out of the training.

Source code available on GitHub:

Type: Training (180 mins); Python level: Advanced; Domain level: Intermediate

Francesco Pierfederici


CTO with strong engineering background.

Launched genomics data processing platform for the largest food company in the world.
Helped shoot satellites in orbit at NASA.
Optimised numerical weather forecast models on 200k cores.
Asteroid 22435 Pierfederici named in recognition of his contributions to astronomy software development.
Author of "Distributed Computing with Python", 2016 PACKT Publishing.

Loves Python.