Mypy: Optional Static Typing for Python
Wasim Thabraze (~waseem18) |
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,
- PEP-484 and Introduction of type annotations in Python 3.5 (6 min)
- Use cases of Mypy and how to use it with Python 2 and 3 (8 min)
- Project typeshed and how to leverage it (3 min)
- Lessons I learned by type hinting projects like Texttable and Twine (6 min)
Prerequisites:
- Knowledge of Python
- 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