Static typing: beyond the basics of def foo(x: int) -> str:

Exploring the practicalities of explaining complex code to mypy

Vita Smid

Static Analysis Type-Hinting

See in schedule Download Slides

The Python community has been warming up to static typing for a few years now. You may have seen talks that did a great job of introducing the basic concepts, mypy, and high-level strategies to cover existing code bases.

We need to go deeper.

Let’s talk about the challenges you inevitably encounter when you try to type-check a large code base. One full of many moving parts, complex architectures, metaprogramming tricks, and interfaces with a dozen other packages.

Static type checking is very powerful – when you use it to maximum advantage and explain your code to the typechecker accurately. We will cover a few tools at your disposal: generics, signature overloads, protocols, custom mypy plug-ins, and more.

There is more than just tools, though. Behind them all are universal concepts valid in any language. I hope to convince you that thinking in terms of the type system helps you write better code…

Type: Talk (30 mins); Python level: Intermediate; Domain level: Intermediate

Vita Smid


I am the CTO at Quantlane where we trade stocks using Python 3. Before starting Quantlane I studied financial mathematics and worked as a nomadic freelance developer. I like asyncio, Scotch whisky, type hinting, and motorbikes.