Mypy is an incredibly useful tool for checking python code quality. It is more specifically a static type checker.
If you have not checked it out, I definitely recommend!
There are also many articles on why you SHOULD be type checking your python code. This is something I have begun doing consistently on anything outside of a jupyter notebook script. There are a few benefits to this.
- Code is more self documenting
- They are optional, use when appropriate
- Allows better code completion for most IDEs
- Easier to find and fix errors (mypy)
That being said, if you do use it, I recommend an automated Github Action to run it!
Mypy Github Action
Here is the action I use in my projects.
Once you add this to your project, the next time you commit you will see the new action run!
That is it! Only thing to note is that my workflow runs against my src/
folder. If your code is in another directory, or you want to run on root, make sure to change that path appropriately.
Thanks!