How do I diagnose why `pants check --only=mypy src...
# general
g
How do I diagnose why
pants check --only=mypy src/python/::
says a library is missing even though it's defined in the requirements.txt (mypy-requirements.txt)?
Copy code
# 3rdparty/python/BUILD.pants
python_requirements(
    name="mypy",
    source="mypy-requirements.txt",
    resolve="mypy",
    overrides={
        "mypy": {"entry_point": "mypy.__main__:console_entry"},
    },
    type_stubs_module_mapping={
        "types-python-dateutil": ["dateutil", "dateutil.parser"],
    },
)

# 3rdparty/python/mypy-requirements.txt
mypy>=1.0.0,<2.0.0
types-python-dateutil>=2.9.0.20240906,<3.0.0.0
types-cachetools>=5.5.0.20240820,<6.0.0

# pants.toml
[mypy]
install_from_resolve = "mypy"
requirements = ["//3rdparty/python:mypy"]
Copy code
src/python/nexus_tenant_client/models/organization.py:6: note: Hint: "python3 -m pip install types-python-dateutil"
src/python/nexus_tenant_client/models/organization.py:6: note: (or run "mypy --install-types" to install all missing stub packages)
src/python/nexus_tenant_client/models/organization.py:6: note: See <https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports>
1
I've even tried adding an explicit dependency in an override
b
I believe you’re running into this issue: https://github.com/pantsbuild/pants/issues/21114 I think the type stubs need to be in the same resolve as the code, not the same resolve as mypy
g
ahh, how confusing!
but it makes sense
b
I updated the docs after that to state it a bit more clearly, but that may not have made it in yet for older releases
g
yeah, I was looking at 2.21 docs
Thanks, @better-van-82973
It's a miracle! It works! 🎉
🎉 1