Skip to content

Remove distribution metadata when unregistering plugins - #764

Closed
jovial-liu wants to merge 1 commit into
pytest-dev:mainfrom
jovial-liu:fix/unregister-plugin-distributions
Closed

jovial-liu wants to merge 1 commit into
pytest-dev:mainfrom
jovial-liu:fix/unregister-plugin-distributions

Conversation

@jovial-liu

@jovial-liu jovial-liu commented Oct 8, 2026 •

Copy link
Copy Markdown

After unloading an entry-point plugin, both distribution-list APIs still include it; loading it again adds a duplicate row. This also affects consumers such as pytest's plugin header.

Remove metadata for the registry object actually removed by unregister(), using identity checks and updating the existing metadata list in place. The regression loads two plugins through real on-disk .dist-info entry points, then checks removal by object/name/both arguments, an equal lookup object, blocking, preservation of the sibling plugin, and reloading through both distribution-list APIs. Add a bugfix changelog fragment.

Fixes #763. This complements the unregister argument validation and falsey-plugin handling in #759.

Validation on macOS, CPython 3.12.14:

  • New regression against the original code: 5 failed.
  • Full suite: 208 passed with pytest 9.1.1 and pytest-benchmark 5.3.0, using uv run --with 'pytest>=8' --with 'pytest-benchmark>=4' --with-editable . pytest.
  • uv run pre-commit run -a: all hooks passed, including Ruff, autoflake, documentation checks, and mypy. Hook-modified files were reread and the full suite was rerun.

The repository's uv.lock currently pins pytest 3.2.5, which fails to start on Python 3.12 because it imports imp. The temporary test overlay uses the checkout's editable pluggy; the lock file is unchanged.

Prepared and tested with OpenAI Codex, with an independent agent code review. No manual human review is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list_plugin_distinfo() keeps unregistered plugins

2 participants