pytest-dev / pytest-dev/pluggy

Feature request: declarative ordering of hookimpls relative to other plugins (before/after), beyond tryfirst/trylast

Open
#705 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
160
Avg merge
21h 4m
Merged PRs (30d)
6

Description

pluggy currently offers only tryfirst and trylast booleans to control hook order, which remains arbitrary within each of the three categories. Some users want to declare that their hookimpl must run before or after a specific other plugin or hookimpl, and so several pytest issues conclude that the fix (if any) belongs in pluggy:

  • pytest-dev/pytest#13371 — "Provide a better way to schedule hooks ordering." Request for before=/after= ordering relative to named plugins.
  • pytest-dev/pytest#2364 — "undeterministic order of pytest_configure for conftest-loaded plugins." Core/entrypoint/conftest plugins end up in an effectively random relative order; the issue explicitly notes "this may need actual dependency ordering support in pluggy."
  • #250 — an existing user question about reordering hookimpls after registration by poking _HookCaller._nonwrappers (private API), which shows people already reach for unsupported internals to get this.

Personally I'm inclined to close this issue as wontfix, because it's absolutely classic "what if two programs did this" fodder. Even if we proposed to error on such cases and do a fancy toposort on the rest, I don't think it'd be worth the complexity.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the current tryfirst and trylast hook ordering behavior and the referenced pytest issues. The issue also identifies _HookCaller._nonwrappers as a private API users inspect today. Done would require an accepted design for declarative ordering, including conflicts and cycles, followed by implementation and tests; the maintainer currently questions whether it is worthwhile.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.