Skip to content

Prefer valid distributions when collecting entry points#536

Open
gaoflow wants to merge 1 commit into
python:mainfrom
gaoflow:fix-534-entry-points-prefer-valid-dist
Open

Prefer valid distributions when collecting entry points#536
gaoflow wants to merge 1 commit into
python:mainfrom
gaoflow:fix-534-entry-points-prefer-valid-dist

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 19, 2026

Copy link
Copy Markdown

Fixes #534

Summary

  • add a duplicate-aware distribution selector for entry_points() that replaces an invalid/empty dist-info entry with a later valid distribution of the same normalized name
  • keep normal discovery order for unique distributions, avoiding the broader cost of preferring valid metadata for every distribution
  • add a regression test where an empty older foo.dist-info appears before a valid one with entry points

Tests

  • Red before the fix: PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_main.py::InvalidMetadataTests::test_entry_points_prefer_valid_distribution -q failed with KeyError: '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.

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.

entry_points doesn't handle empty .dist-info files well

1 participant