Skip to content

feat(project): add ProjectSpec hub for markers and PluginManager - #709

Draft
RonnyPfannschmidt wants to merge 5 commits into
pytest-dev:mainfrom
RonnyPfannschmidt:refactor/project-spec
Draft

RonnyPfannschmidt wants to merge 5 commits into
pytest-dev:mainfrom
RonnyPfannschmidt:refactor/project-spec

Conversation

@RonnyPfannschmidt

@RonnyPfannschmidt RonnyPfannschmidt commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Written by Claude Opus 5.5 via Claude Code for the pluggy maintainers; I prompted it, it did the work, I read it.

Step 6 of 7, merges bottom-up: #703 → #704 → #706 → #707 → #708 → #709 → #710
The diff here is cumulative (steps 2–6); RonnyPfannschmidt#10 shows this step alone.

  • ProjectSpec bundles a project's HookspecMarker, HookimplMarker and create_plugin_manager() under one project name.
  • HookspecMarker, HookimplMarker and PluginManager accept str | ProjectSpec; plain strings work unchanged. Purely additive.

@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the refactor/project-spec branch 2 times, most recently from 3ce85b3 to d6217b7 Compare July 24, 2026 16:54
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the refactor/project-spec branch 3 times, most recently from b74f215 to 95512c2 Compare August 12, 2026 11:14
@RonnyPfannschmidt
RonnyPfannschmidt marked this pull request as draft September 9, 2026 20:20
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the refactor/project-spec branch 3 times, most recently from e452089 to 96a1722 Compare September 24, 2026 11:24
RonnyPfannschmidt and others added 5 commits September 24, 2026 13:47
Markers attach HookspecConfiguration/HookimplConfiguration objects.
Registration discovers those privately; parse_hookimpl_opts and
parse_hookspec_opts remain a deprecated pytest concession that returns
legacy dicts and is only called when a subclass overrides them and no
modern configuration attribute was found.

Co-authored-by: Cursor AI <ai@cursor.sh>
Co-authored-by: Cursor Grok 4.5 <grok@cursor.com>
Complete design step 03: markers already attach configuration objects
since step 02; this finishes the step by storing the spec configuration
as HookSpec.config (try-claude naming) with a deprecated .opts alias,
reading .config in HookCaller firstresult resolution, and covering
decoration-time historic+firstresult validation and configuration
attachment with tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… setup API

Complete design step 04:

- HookImpl becomes a base class storing hookimpl_config (deprecated
  .opts alias kept) with arg binding moved to _get_call_args.
- NormalImpl / WrapperImpl subclasses validate their configuration;
  HookimplConfiguration.create_hookimpl() returns the right subclass
  (fixing the try-claude footgun of bare HookImpl for normals).
- WrapperImpl.setup_and_get_completion_hook() runs wrapper setup and
  returns a CompletionHook (runtime-checkable Protocol) that owns
  teardown, adapting old-style hookwrappers uniformly.
- Registration and call_extra construct impls via create_hookimpl;
  multicall binds args via _get_call_args. Full dual-sequence multicall
  rewiring lands with design step 05.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…multicall

Complete design step 05:

- HookCaller is now a @runtime_checkable Protocol; concrete callers are
  NormalHookCaller (split list[NormalImpl] / list[WrapperImpl] storage),
  HistoricHookCaller (memorize/replay, rejects wrappers) and
  SubsetHookCaller (read-only filtered proxy). _HookCaller and
  _SubsetHookCaller remain as compat aliases.
- _multicall takes dual sequences and orchestrates phases only: wrapper
  setup collects CompletionHooks, normals run, completion hooks run LIFO
  and may replace (result, exception) - no wrapper flag branching.
- add_hookspecs hands a NormalHookCaller over to a HistoricHookCaller
  when a historic spec arrives after impl registration.
- PluginManager._hookexec and tracing use the dual-sequence signature;
  monitoring callbacks keep receiving one combined impl list.
- HookSpec.verify_all_args_are_provided replaces the caller-side helper;
  set_specification accepts a config object or legacy mapping (shim).
- New tests: protocol isinstance for all concretes, historic handover,
  historic direct-call/call_extra rejection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Complete design step 06: ProjectSpec bundles hookspec/hookimpl markers
and plugin manager creation under a single project name, with
get_hookspec_config / get_hookimpl_config helpers. Markers and
PluginManager accept str | ProjectSpec (strings still work; markers and
manager now expose project_name as a property delegating to the spec).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant