Sheena O'Connell

Accepted Talks:

Hello Types


Lately there has been drive toward adding static typing to dynamically typed languages. Clojure, Javascript and Lua are some examples of this. And of course Python. Why? Because it's a damn fine idea! Having a variable and knowing what it is and how it behaves and being able to enforce that in your code is golden.

In this tutorial session we'll briefly cover some of the pros and cons of Python type checking (mostly the pros to be honest) and then get our hands dirty. We'll start off with writing some fresh code and adding Type annotations as we go. We'll then cover a bit of how to add type checking to pre-existing codebases.

Prerequisite skillz:

Basic knowledge of Python. If you can run your code and you are comfortable with the syntax around variables, functions, classes and loops then you should be quite comfortable. It would also be useful if you know how to drive a virtalenvironment but this is not strictly necessary.

Prerequisite tech:

We'll be working in both Python2 and 3. You'll need to bring a laptop with the following things installed:

Most of this tutorial will be in Python3.6+:

  • Python3.6+
  • python3 -m pip install mypy
  • python3 -m install typingextensions

We will also cover type checking in Python2.7:

  • Python2.7
  • python -m pip install typing

You are welcome to use virtual environments or pipenv.

What we'll cover

  • What is type checking and why should we use it?
  • Python3 type annotations
  • Python2 type annotations
  • Adding annotations to existing projects

By the end of this you...

Should be able to consistently write saner, more robust and more explicit code. Which is always a worthwhile goal