As Python developers we are fond of the dynamic nature of the language. Sometimes, though, it can get a bit too dynamic and that’s where having some type information would come in handy. Mypy is a project that aims to add that missing level of detail to function and variable definitions so that you don’t have to go hunting 5 levels deep in the stack to understand what shape that data structure is supposed to be. This week we spoke with David Fisher and Greg Price about their work on Mypy and its use within Dropbox and the broader community. They explained how it got started, how it works under the covers, and why you should consider adding it to your projects.
Do you want to try out some of the tools and applications that you heard about on Podcast.__init__? Do you have a side project that you want to share with the world? With Linode’s managed Kubernetes platform it’s now even easier to get started with the latest in cloud technologies. With the combined power of the leading container orchestrator and the speed and reliability of Linode’s object storage, node balancers, block storage, and dedicated CPU or GPU instances, you’ve got everything you need to scale up. Go to pythonpodcast.com/linode today and get a $60 credit to launch a new cluster, run a server, upload some data, or… And don’t forget to thank them for being a long time supporter of Podcast.__init__!
Stop hoping your users will report bugs. Sentry’s real-time tracking gives you insight into production deployments and information to reproduce and fix crashes. Use the code podcastinit at signup to get a $50 credit!
- Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
- I would like to thank everyone who has donated to the show. Your contributions help us make the show sustainable. For details on how to support the show you can visit our site at pythonpodcast.com
- Linode is sponsoring us this week. Check them out at linode.com/podcastinit and get a $20 credit to try out their fast and reliable Linux virtual servers for your next project
- We are also sponsored by Sentry this week. Stop hoping your users will report bugs. Sentry’s real-time tracking gives you insight into production deployments and information to reproduce and fix crashes. Check them out at getsentry.com
- Visit our site to subscribe to our show, sign up for our newsletter, read the show notes, and get in touch.
- To help other people find the show you can leave a review on iTunes, or Google Play Music, and tell your friends and co-workers
- Join our community! Visit discourse.pythonpodcast.com for your opportunity to find out about upcoming guests, suggest questions, and propose show ideas.
- Your hosts as usual are Tobias Macey and Chris Patti
- Today we’re interviewing David Fisher and Greg Price about Mypy, a library for adding optional static types to your Python code.
Interview with David Fisher and Greg Price
- How did you get introduced to Python? – Chris
- Can you explain a bit about what Mypy is and its origin story? – Tobias
- What are the benefits of using Mypy for both new and existing projects? – Tobias
- How does the Mypy compilation step work? – Tobias
- What are the biggest technical challenges in implementing Mypy? – Chris
- Are there any limitations imposed by the syntax of Python that prevented you from implementing any features or syntax that you would have liked to include in Mypy? – Tobias
- In Guido’s keynote from this year’s PyCon he mentioned some tentative plans for adding variable type declarations to the Python syntax in one of the next major releases. How much of that idea was inspired by Mypy? – Tobias
- Type theory is a large and complex problem domain. Can you explain where Mypy falls in this space? – Tobias
- Which language(s) had the biggest influence on the particular syntax and semantics used in Mypy? – Tobias
- What kinds of type definitions and guarantees can be encoded using Mypy? – Tobias
- Can you talk a bit about user defined types as implemented in Mypy? – Chris
- How has the inclusion of the typing module in the Python standard libary influenced the evolution of Mypy? – Tobias
- Did the inclusion of multiple inheritance add any implementation complexity to Mypy? – Chris
- Do you know of any formal studies that have been performed to research the ergonomics or efficiency gains of static or gradual type systems? – Tobias
- What does the future roadmap for Mypy look like? – Tobias
Keep In Touch
$ pip3 install mypy-lang
Bug reports, feature requests, questions welcome on issue tracker: github.com/python/mypy
- GitHub repo, and CONTRIBUTING file
- PEP 484
- PyCon 2016 workshop slides
- Typeshed shared repo for stubs
- Other tools (PyCharm, pylint, pytype, …) using PEP 484 types