Mypy: Optional Static Typing for Python

Wasim Thabraze (~waseem18)


7

Votes

Description:

Large Python codebases can be hard to maintain. If we make it easier to understand our code bases, we make everyone more productive and help each other write fewer bugs. Static typing is one of remedies that can improve readability and maintainability of the code.

That's why Python now features optional static typing as described in PEP-484, implemented as Mypy.

Mypy is an experimental variant of Python that let's you add optional type annotations to type check your Python code. And it works great on both Python 2.7 and 3.3+.

Adopting static typing is easier that you think, you can start on a small set of code and move on to bigger pieces.

In this talk I'll share about,

  1. PEP-484 and Introduction of type annotations in Python 3.5 (6 min)
  2. Use cases of Mypy and how to use it with Python 2 and 3 (8 min)
  3. Project typeshed and how to leverage it (3 min)
  4. Lessons I learned by type hinting projects like Texttable and Twine (6 min)

Prerequisites:

  1. Knowledge of Python
  2. Difference between dynamic and statically typed languages

Content URLs:

Slides : https://docs.google.com/presentation/d/1zNFGNy2BMBYQvZypkH8Iql-WRx--6Ddg8Ft33intWjM/edit?usp=sharing (WIP)

Stub file for the project Texttable : https://github.com/foutaise/texttable/pull/46/files

Mypy travis job configuration : https://github.com/pypa/twine/pull/380

Article on Medium about Mypy : https://medium.com/@thabraze/mypy-optional-static-typing-for-python-dbc53b82f1ef

Speaker Info:

Wasim is a Senior Software Engineer at Zemoso Labs, Hyderabad. He's an open source fanatic who loves to create meaningful software and contribute to open source projects.

Some of his contributions are included in projects like Sendgrid, Warehouse, Twine and Hazelcast.

Apart from programming he also tweets.

You can find him interesting on his GitHub profile.

Speaker Links:

Portfolio : www.thabraze.me

GitHub : https://github.com/waseem18

Twitter: imwaseem18

LinkedIn : https://in.linkedin.com/in/thabraze

Section: Core python and Standard library
Type: Talks
Target Audience: Intermediate
Last Updated: