Another helpful tool when getting started with typing in Python is MonkeyType 1. It lets you record types during execution and proposes patches to add annotations to you function signatures. Helped me to get annotations into a typing-free code base quickly.
I had success with MyPy typing the whole Oil front end back in the spring, and I plan to complete this by adding types to the rest of the codebase. If anyone is interested in getting to know the codebase, adding these annotations is probably a good way:
I made some example commits here:
And there are a whole bunch of experiences on the Zulip thread linked in the issue. For example, it seems to help to start with files that are the dependency leaves. And I prevent regressions by type checking in the Travis continuous build, etc.
I should have mentioned the main motivation for this is to automatically translate Oil to C++, which has made a bunch of progress in the last month. A few thousand lines of Oil translates and compiles as C++. Some of it runs too :)
So while I’m working on this auto-translation (and writing docs, etc.) it would be nice to make progress on type checking coverage in parallel!
Sounds like I should really give mypy a try. For my big project, rewriting from Perl to Python was a huge improvement, but type errors are still common.
Highly recommend trying! Mypy has completely changed my python experience from type error frustration and having to read the code all over again to understand what it actually does to something pleasant and safe to use.