Want to add type annotation to a variable? Do refactoring!

Posted on Thu, 06 Oct 2016 in Python • Tagged with python, type hinting

There is the PEP 526 implemented in Python 3.6 that adds optional type annotations for variables. It's replacement for type comments. There is one pitfall: adding type annotations for local variables can hide problems with code.


Continue reading

How to use mypy on Python 2.7 project

Posted on Fri, 29 Jul 2016 in Python • Tagged with python, mypy, type hinting

If you work on a big Python project, type hinting can help you to find many design and function usage problems. Of course, you have to use external tools for static analysis, such as mypy. This is a great tool, but supports Python 3 mainly. Support for 2.7 branch isn't so straightforward. There are a couple of tricks that allows you to use it for 2.7.


Continue reading