Closed jaraco closed 1 month ago
Those errors don't happen on main, but I don't know why.
I can replicate the errors locally by running mypy manually, but there's no difference between the branch and main:
setuptools feature/skeleton @ .tox/py311/bin/mypy .
setuptools/config/_validate_pyproject/formats.py:180: error: Cannot find implementation or library stub for module named "trove_classifiers" [import-not-found]
setuptools/config/_validate_pyproject/formats.py:180: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 147 source files)
setuptools feature/skeleton @ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
setuptools main @ .tox/py311/bin/mypy .
setuptools/config/_validate_pyproject/formats.py:180: error: Cannot find implementation or library stub for module named "trove_classifiers" [import-not-found]
setuptools/config/_validate_pyproject/formats.py:180: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 147 source files)
Moreover, mypy config explicitly excludes the erroring file:
https://github.com/pypa/setuptools/blob/6ee23bf0579c52e1cbe7c97fc20fd085ff2a25c7/mypy.ini#L9-L17
What the heck?
There is literally nothing about this change that should affect mypy.
I thought I'd found a patch that would work around the issue. I made this change:
diff --git a/mypy.ini b/mypy.ini
index 90c8ff13e..30fc1da2d 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -25,7 +25,8 @@ disable_error_code = attr-defined
# https://github.com/pypa/setuptools/pull/3979#discussion_r1367968993
# - distutils._modified has different errors on Python 3.8 [import-untyped], on Python 3.9+ [import-not-found]
# - All jaraco modules are still untyped
-[mypy-pkg_resources.extern.*,setuptools.extern.*,distutils._modified,jaraco.*]
+# - _validate_project starts complaining about trove_classifiers
+[mypy-pkg_resources.extern.*,setuptools.extern.*,distutils._modified,jaraco.*,trove_classifiers]
ignore_missing_imports = True
# - pkg_resources tests create modules that won't exists statically before the test is run.
and the mypy tests stopped failing. Then I stashed the change and the tests continue to pass. I can't get the failure to happen reliably. I thought maybe the issue was pytest==8.1.1 vs pytest==8.0.2, but that doesn't seem to be a factor.
I've figured out that removing ./.mypy_cache
between runs makes the failure more consistent with the configuration, but leaving it in place causes a setting of ignore_missing_imports
to be sticky for trove_classifiers
even after removing it.
I really don't understand why ignore_missing_imports
for trove_classifiers
is relevant anyway, since that module is never imported (it's not installed).
Tests are failing with this mypy error: