Mypy type checking workflow for new model development

Hi, I’m developing support for a new model architecture in the MAX framework. My current iterative development workflow is as follows:

  1. Make code changes
  2. Run ./bazelw run format to ensure code consistency
  3. Build with ./bazelw build //max/... to verify compilation and logic

Currently, Mypy type checking errors are only surfaced during the full build process. However, ./bazelw run format does not catch these errors, as it focuses on formatting (buildifier, ruff, markdownlint, mblack) rather than static type analysis. This makes the feedback loop for type errors significantly slower due to the build overhead.

So, my questions are

  1. Is this the intended workflow? Should Mypy errors only be validated during a build, or am I missing a pre-build check step?
  2. Is there a way to run Mypy checks in isolation? Running a full build just to see type errors is time-consuming. Is there a standalone command for Mypy checking within the Bazel setup?
  3. Should Mypy be integrated into the format or lint workflow? Or is it intentionally kept separate due to performance or other reasons?

These commands are I’m Using

# Formatting (Fast, but doesn't catch type errors)
./bazelw run format

# Building (Slow, but surfaces Mypy errors)
./bazelw build //max/...
  1. Yes, currently mypy runs during build and not during format/lint.

  2. I recommend to build a specific target for faster build like

./bazelw build //max/python/max/pipelines:pipelines

or can use --config=disable-mypy during iteration for faster build and remove it for final check.

  1. mypy requires dependency tracking and resolution so can be slow but format/lint work on raw files which is fast.
1 Like

+1 on everything Ehsan said, but just to note that you can get slightly faster feedback with ./bazelw build //max/python/max/…, this will skip things like the kernels tests to save you some time. Can also lump in tests with something like ./bazelw build //max/python/max/… //max/tests/…

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.