quaint-telephone-89068
10/16/2025, 2:56 AMpants check :: in an internal Python repository I get 75 inscrutable mypy errors that were not present before. I use mypy.install_from_resolve so this is unrelated to the specific version of mypy. The exact errors seem to vary in a 'spooky' way based on which targets I check.
From git bisect I've narrowed this down to da7cba5 (#22578). Prior to that change we would generate __run.sh scripts that look like:
-env -i MYPYPATH=$'my:source:roots' MYPY_FORCE_COLOR=1 MYPY_FORCE_TERMINAL_WIDTH=642092230765939 PEX_EXTRA_SYS_PATH=$'my:source_roots' TERM=ansi ./__mypy_runner.sh
But with that change the command instead has PEX_EXTRA_SYS_PATH=''. This is presumably due to:
diff --git a/src/python/pants/backend/python/typecheck/mypy/rules.py b/src/python/pants/backend/python/typecheck/mypy/rules.py
index 0c31d1f6d8..449bf0d47a 100644
--- a/src/python/pants/backend/python/typecheck/mypy/rules.py
+++ b/src/python/pants/backend/python/typecheck/mypy/rules.py
@@ -4,7 +4,6 @@
from __future__ import annotations
import dataclasses
-import itertools
from collections.abc import Iterable
from dataclasses import dataclass
from hashlib import sha256
@@ -336,12 +335,9 @@ async def mypy_typecheck_partition(
)
)
- all_used_source_roots = sorted(
- set(itertools.chain(first_party_plugins.source_roots, closure_sources.source_roots))
- )
env = {
- "PEX_EXTRA_SYS_PATH": ":".join(all_used_source_roots),
- "MYPYPATH": ":".join(all_used_source_roots),
+ "PEX_EXTRA_SYS_PATH": ":".join(first_party_plugins.source_roots),
+ "MYPYPATH": ":".join(closure_sources.source_roots),
# Always emit colors to improve cache hit rates, the results are post-processed to match the
# global setting
"MYPY_FORCE_COLOR": "1",
Possible Slack Thread Breadcrumb: https://pantsbuild.slack.com/archives/C046T6T9U/p1661627014305049
I am uncertain why pantsbuild/pants itself is unaffected. Perhaps generated protocal buffers are part of the puzzle?
pantsbuild/pants