Skip to content

Restore class-valued hook specifications - #795

Closed
adenzhou1350 wants to merge 3 commits into
pytest-dev:mainfrom
adenzhou1350:codex/fix-class-hookspec-compat
Closed

adenzhou1350 wants to merge 3 commits into
pytest-dev:mainfrom
adenzhou1350:codex/fix-class-hookspec-compat

Conversation

@adenzhou1350

Copy link
Copy Markdown

Fixes #794.

PluginCode decorates a class as a hookspec. The static-discovery change in 1.7.0 stopped recognizing that class, so add_hookspecs() raises ValueError.

Restore class-valued specifications without changing hook implementation discovery or evaluating properties/other descriptors. For a class signature, read defaults from its __init__, matching the callable already inspected by varnames(). Classes using object.__init__ have no defaults. Keep the original class in HookSpec.function.

Tests cover module/class/instance namespaces and implicit, required, defaulted, inherited and wrapped constructors. They verify argument metadata, explicit/default hook calls, and that constructors are never executed. A control preserves the existing behavior of ignoring class-valued hook implementations.

Validation

  • Final regression tests against unchanged main: 15 failed, 1 control passed.
  • Candidate full suite: 235 passed on Windows CPython 3.14 / pytest 9.0.3 and Linux CPython 3.12 / pytest 9.1.1.
  • Mypy and cached non-Ruff pre-commit hooks passed; no formatter changes. Local Ruff is blocked by Windows policy and was not rerun elsewhere. The cached pyupgrade hook is 3.21.2 rather than the current 3.22.0, so this is not a full current pre-commit pass.
  • Tests used exact source selection with existing dependency environments, not a fresh uv-locked build. Full ScanCode/PluginCode integration was not run.

Reproduction context: #794 (comment)

AI-assisted implementation and validation.

Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
Xucheng Zhou added 2 commits October 15, 2026 21:44
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

this is a prime example of what destroys opensource - unattended ai slop adding a fix that eats review time when the only correct answer is - no this never was intended

the person operating the bot should be ashamed of their behavior

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.

Pluggy 1.7.0 breaks scancode-toolkit

2 participants