1. Setup

  1. Update your requirements-dev.txt to include line:
  2. Install it using one of the following:
     $ pip install mypy
     $ pip install -r requirements-dev.txt
     $ make install-dev
  3. Update .gitignore to include this line:

2. Validate types

Add type checks to you .py files.

Check types directly.

$ mypy my_project tests

Or with make:

  1. Add target to Makefile. With specific directories to check as args. e.g.
         mypy my_project tests
  2. Check types.
     make typecheck

Or check-types or type-check.

3. Add to CI/CD pipeline

Add a step your pipeline such GitHub Actions.

  • main.yml
        - name: Check types
          run: make check-types