tinypilot icon indicating copy to clipboard operation
tinypilot copied to clipboard

Research: Explore type-enforcement

Open mtlynch opened this issue 3 years ago • 0 comments

We've started documenting the types of function parameters in our Python docstrings. If we're doing that, we might as well do it programmatically so that static tools can verify the types for us.

What are our options for type enforcement in Python?

There's the native typing module as well as mypy. Are there other options? What are the tradeoffs between the available options?

The Google Python Style Guide now has guidance about type checking, but we don't necessarily have to adopt their strategy, as they're working under different constraints:

https://google.github.io/styleguide/pyguide.html#221-type-annotated-code

Blog posts about migrating to mypy

  • https://calpaterson.com/mypy-hints.html
  • https://blog.buttondown.email/2022/01/19/buttondown-mypy
  • https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy/

mtlynch avatar Jan 12 '22 16:01 mtlynch