Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from skeleton #4296

Merged
merged 11 commits into from
Apr 11, 2024
Merged

Merge changes from skeleton #4296

merged 11 commits into from
Apr 11, 2024

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Apr 11, 2024

No description provided.

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

Tests are failing with this mypy error:

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

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

Those errors don't happen on main, but I don't know why.

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

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)

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

Moreover, mypy config explicitly excludes the erroring file:

setuptools/mypy.ini

Lines 9 to 17 in 6ee23bf

exclude = (?x)(
^build/
| ^.tox/
| ^.egg/
| ^pkg_resources/tests/data/my-test-package-source/setup.py$ # Duplicate module name
| ^.+?/(_vendor|extern)/ # Vendored
| ^setuptools/_distutils/ # Vendored
| ^setuptools/config/_validate_pyproject/ # Auto-generated
)

What the heck?

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

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.

@jaraco
Copy link
Member Author

jaraco commented Apr 11, 2024

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).

Under some circumstances not fully understood, mypy has started complaining when `_validate_project` tries to import `trove_classifiers` (and it doesn't exist), even though `_validate_project` is excluded from mypy checks. Mysteriously, adding `trove_classifiers` itself to the list of modules for which to ignore imports suppresses this mysterious failure.

Ref #4296.
@jaraco jaraco merged commit bb2f767 into main Apr 11, 2024
36 checks passed
@jaraco jaraco deleted the feature/skeleton branch April 11, 2024 19:39
carljm added a commit to carljm/setuptools that referenced this pull request Apr 11, 2024
pypa#4296 broke `ruff.toml`, by adding a second `extend-select` section. Merge them to fix ruff checking.
@carljm carljm mentioned this pull request Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants