1. 29
  1.  

  2. 5

    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:

    https://github.com/oilshell/oil/issues/518

    I made some example commits here:

    https://github.com/oilshell/oil/commit/6155a0f0e3bb286c52a67ddb2c0dce77f2eaa8cc

    https://github.com/oilshell/oil/commit/56779760c70313c45096ed71593950f250fdfe43

    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.

    1. 4

      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 :)

      https://github.com/oilshell/oil/tree/master/mycpp/examples

      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!

    2. 5

      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.

      1. 4

        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.

        1. 2

          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.