Point the missing-argument warning at the code making the hook call - #727
Open
dylanpulver wants to merge 2 commits into
Open
Point the missing-argument warning at the code making the hook call#727dylanpulver wants to merge 2 commits into
dylanpulver wants to merge 2 commits into
Conversation
The warning for hookspec arguments missing from a hook call was moved out of HookCaller.__call__ and into _verify_all_args_are_provided in e77787b, so that call_historic could share it, but it kept stacklevel=2. Inside the helper that level is __call__ itself, so every such warning is attributed to pluggy's own frame in _hooks.py rather than to the caller. All three entry points reach the helper at the same depth, so stacklevel=3 restores the pre-e77787b attribution for __call__ and extends it to call_historic and call_extra. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The warning for hookspec arguments missing from a hook call is attributed to pluggy's own frame instead of to the code that made the call:
e77787b("hooks: also verify kwargs are per spec in call_historic") moved thewarnings.warnout ofHookCaller.__call__and into the new_verify_all_args_are_providedsocall_historiccould share it, and carriedstacklevel=2over unchanged. Inside__call__that level was the caller; inside the helper it is__call__itself. All three entry points call the helper directly, so all three are off by the same one:__call___hooks.py:539call_historic_hooks.py:559call_extra_hooks.py:580stacklevel=3restores the pre-e77787bbehaviour for__call__and extends it to the two paths that never had it.test_not_all_arguments_are_provided_issues_a_warningalready covers all three paths, but only matches the message, so the attribution regressed silently. The new test assertsrecord[0].filename == __file__for each path; withstacklevel=2restored it fails and nothing else does.pytest testing/: 145 passed (144 passed / 1 failed on the reverted source).pre-commit run --files src/pluggy/_hooks.py testing/test_details.py: ruff check, ruff format, autoflake, pyupgrade, blacken-docs and mypy all pass.Happy to add a
changelog/<PR>.bugfix.rstfragment once this has a number, or to drop the test if you would rather keep the assertion to the message only.🤖 Generated with Claude Code
https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo