Prefer valid distributions when collecting entry points - #536
Conversation
|
I've not tested this but I'm not convinced it will actually work in all cases. Our reason for this is that thanks to package upgrades and removals we'll end up with eg This is discovered as a distribution, and because |
|
I take that back, latest importlib_metadata has different behaviour and correctly raises an exception. |
|
I must admit I don't understand the reasoning behind returning invalid distributions at all: if some empty directories that look like a dist but have no content are found, why return them at all? |
Fixes #534
Summary
entry_points()that replaces an invalid/empty dist-info entry with a later valid distribution of the same normalized namefoo.dist-infoappears before a valid one with entry pointsTests
PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_main.py::InvalidMetadataTests::test_entry_points_prefer_valid_distribution -qfailed withKeyError: 'main'\n-PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_main.py::InvalidMetadataTests::test_entry_points_prefer_valid_distribution -q\n-PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_main.py::InvalidMetadataTests tests/test_api.py::APITests::test_entry_points tests/test_api.py::APITests::test_entry_points_unique_packages_normalized -q\n-PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest -q\n-PYTHONPATH=. uv run --python 3.11 --with '.[test,check]' pytest --ruff -q\n-PYTHONPATH=. uv run --python 3.11 --with '.[test,type]' pytest --mypy -q\n-git diff --check\n\nAI assistance was used under my direction.