Using typing.Generic in Python

Posted on Fri, 18 Feb 2022 in Python • Tagged with python, type hints, typing, mypy, PyCharm

I am working on a project with a relatively large code-base. And it has a history. Our team wrote some parts of it way before type-hints. And we steel add hints to the legacy code or improve them. Is it worth the fuss? Sure! Our users are developers. They open our code in PyCharm every day. And they hope that it will help them to solve their task as quickly as possible.


Continue reading

Tuple[Callable, Any, ...]

Posted on Mon, 29 Jan 2018 in Python • Tagged with typing, mypy, python

Type hints could help you a lot with a big Python project. However, they sometimes require code refactoring. I wrote about it last year in this article, but I have found a good example for this only now.


Continue reading

How to add type hints into Python 2.7 project

Posted on Mon, 11 Dec 2017 in Python • Tagged with typing, mypy, python

Many times I wrote that type hints in Python help to work with big or moderate projects. However, if you decide to add them to your project, you have to check your project regularly using CI. And this kind of checks is not easy to implement. This article is my story about obstacles in this process.

I'm trying to add type hints to our project for a while. And now I have a bunch of methods how to do it more efficiently, fast, and painless. I spend many days trying to find them. Now I want to share my experience.


Continue reading