-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detailed error message on hook registration conflict #379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for getting this started, the pr is well prepared.
Please have a look at my comments.
src/pluggy/_hooks.py
Outdated
@@ -337,7 +337,11 @@ def set_specification( | |||
specmodule_or_class: _Namespace, | |||
spec_opts: "_HookSpecOpts", | |||
) -> None: | |||
assert not self.has_spec() | |||
if self.spec is not None: | |||
raise RuntimeError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ough to be a ValueError or a subclass of it
testing/test_hookcaller.py
Outdated
pass | ||
|
||
pm.add_hookspecs(Api1) | ||
with pytest.raises(RuntimeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a check for the message, just to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, would you like to compact history or squash?
I usually do squash on merge. Should I do it myself? |
We currently don't have squash merge enabled on the repo, but of you consent to squash I'll happily do it later today after enabling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, would you like to add a CHANGELOG entry as well?
No thank you, it's minor fix. Still can add line if it's required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi! I've spent some time trying to nail down hook registration error:
This PR raises
RuntimeError
with detailed message which should ease developer's life a bit: