Re: [PATCH v2 13/49] perf build: Make mypy build test opt-out (NO_MYPY=1)

From: Ian Rogers

Date: Tue Sep 22 2026 - 13:04:44 EST


On Tue, Sep 22, 2026 at 6:11 AM James Clark <james.clark@xxxxxxxxxx> wrote:
>
> On 21/09/2026 06:06, Ian Rogers wrote:
> > Commit 168910d0f937 ("perf build: Add mypy build tests") added mypy as an
> > opt-in compile-time check (MYPY=1) because of existing mypy errors across
> > perf Python scripts.
> >
> > Now that all Python scripts in tools/perf have been cleaned up and pass
> > mypy without errors, make the mypy build test opt-out (default on when
> > mypy is installed, disabled with NO_MYPY=1), matching NO_SHELLCHECK=1.
> > Set MYPYPATH to tools/perf/python so local imports resolve during type
> > checking, and clean *.mypy_log files in 'make clean'.
> >
> > Assisted-by: Antigravity:gemini-3.1-pro
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> Is there some minimum version or other setup requirement? I get this:
>
>
> pmu-events/amd_metrics.py:181: error: Unsupported operand types for +
> ("Event" and "object") [operator]
> pmu-events/amd_metrics.py:182: error: Unsupported operand types for +
> ("Event" and "object") [operator]
> pmu-events/amd_metrics.py:230: error: Argument 1 to "d_ratio" has
> incompatible type "object"; expected "int | float | Expression" [arg-type]
> pmu-events/amd_metrics.py:231: error: Unsupported left operand type for
> + ("object") [operator]
> pmu-events/amd_metrics.py:236: error: Argument 1 to "d_ratio" has
> incompatible type "object"; expected "int | float | Expression" [arg-type]
> pmu-events/amd_metrics.py:236: error: Unsupported left operand type for
> + ("object") [operator]
> Found 6 errors in 1 file (checked 1 source file)
> make[3]: *** [pmu-events/Build:192:
> /home/james/workspace/linux/build/local/pmu-events/amd_metrics.py.mypy_log]
> Error 1
> make[2]: *** [Makefile.perf:562:
> /home/james/workspace/linux/build/local/pmu-events/pmu-events-in.o] Error 2
> make[2]: *** Waiting for unfinished jobs....
> python/ilist.py:13: error: Cannot find implementation or library stub
> for module named "textual" [import-not-found]
> python/ilist.py:14: error: Cannot find implementation or library stub
> for module named "textual.app" [import-not-found]
> python/ilist.py:15: error: Cannot find implementation or library stub
> for module named "textual.binding" [import-not-found]
> python/ilist.py:16: error: Cannot find implementation or library stub
> for module named "textual.containers" [import-not-found]
> python/ilist.py:17: error: Cannot find implementation or library stub
> for module named "textual.css.query" [import-not-found]
> python/ilist.py:17: note: See
> https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
> python/ilist.py:18: error: Cannot find implementation or library stub
> for module named "textual.command" [import-not-found]
> python/ilist.py:19: error: Cannot find implementation or library stub
> for module named "textual.screen" [import-not-found]
> python/ilist.py:20: error: Cannot find implementation or library stub
> for module named "textual.widgets" [import-not-found]
> python/ilist.py:21: error: Cannot find implementation or library stub
> for module named "textual.widgets.tree" [import-not-found]
> Found 9 errors in 1 file (checked 1 source file)
> make[3]: *** [Build:91:
> /home/james/workspace/linux/build/local/python/ilist.py.mypy_log] Error 1
> make[3]: *** Waiting for unfinished jobs....
> python/treport.py:12: error: Cannot find implementation or library stub
> for module named "textual" [import-not-found]
> python/treport.py:13: error: Cannot find implementation or library stub
> for module named "textual.app" [import-not-found]
> python/treport.py:14: error: Cannot find implementation or library stub
> for module named "textual.binding" [import-not-found]
> python/treport.py:15: error: Cannot find implementation or library stub
> for module named "textual.color" [import-not-found]
> python/treport.py:16: error: Cannot find implementation or library stub
> for module named "textual.scroll_view" [import-not-found]
> python/treport.py:17: error: Cannot find implementation or library stub
> for module named "textual.strip" [import-not-found]
> python/treport.py:18: error: Cannot find implementation or library stub
> for module named "textual.widgets" [import-not-found]
> python/treport.py:19: error: Cannot find implementation or library stub
> for module named "textual.widgets.tree" [import-not-found]
> python/treport.py:19: note: See
> https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
> Found 8 errors in 1 file (checked 1 source file)

Thanks James! So there are 2 issues, and I'll fix the code in v3. The
first issue is that in older mypys the join the plus operator isn't
computed correctly and this can be fixed with a type annotation. The
textual issue is resolvable by running mypy with
--ignore-missing-imports.

Thanks,
Ian