Skip to content

Identify registered plugins and excluded hooks by object identity - #777

Open
00200200 wants to merge 2 commits into
pytest-dev:mainfrom
00200200:codex/plugin-registry-identity
Open

00200200 wants to merge 2 commits into
pytest-dev:mainfrom
00200200:codex/plugin-registry-identity

Conversation

@00200200

Copy link
Copy Markdown

Fixes #760. Distinct plugin objects that compare equal currently interfere with registration, lookup, and removal. Unregistering one can also remove the other's hook implementations.

Use identity for registration checks, name lookup, and hook removal. Subset callers key their exclusion map by object id, retaining object references to prevent id reuse. Blocked names remain distinct from registered plugins. The public set-returning get_plugins() API is unchanged.

Regression tests cover equal unhashable plugins with separate hooks, subset exclusions, unregistering only the intended object, duplicate-object rejection, an eq that raises, and blocked-name sentinels.

Validation (macOS / Python 3.12):

  • Before: all three new regression tests fail.
  • After: 80 manager tests and the full 222-test suite pass.
  • Full pre-commit passes, including mypy.

The committed lock resolves an old pytest/tox combination incompatible with Python 3.12. Tests used PYTHONPATH=src and uv --with overrides for pytest>=8, pytest-benchmark>=5, and tox>=4; no lock or dependency files were changed.

AI assistance: implementation and tests prepared with Codex, then reviewed against the reported case and hook lifecycle.

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.

Plugin registry compares plugins by equality, not identity

1 participant