Skip to content
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

Raise explicit error when impl called with pos args #60

Merged

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented Aug 23, 2017

Raise an explicit TypeError to alert the user that they are calling
a hookimpl incorrectly with positional args; keyword args are allowed
only.

Fixes #53

def __call__(self, *args, **kwargs):
if args:
raise TypeError(
"hookimpl takes keyword arguments only".format(self.name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that message is incorrect and cant hope to be formatted that way

i propose "hook calling supports only keyword arguments" as sole message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yeah.. I changed it 3 times so I'm not surprised.
Thanks for catching / I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RonnyPfannschmidt I just updated the existing test to check for the message.
Hopefully that's cool :)

@RonnyPfannschmidt
Copy link
Member

there also should be an accompanying test

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tgoodlet!

As @RonnyPfannschmidt mentioned, please fix the message and add a test for it.

@goodboy goodboy force-pushed the comprehensible_hook_call_error branch from ce2104b to e2fa34b Compare August 24, 2017 14:59
Raise an explicit TypeError to alert the user that they are calling
a hookimpl incorrectly with positional args; keyword args are allowed
only. Add a test too.

Fixes pytest-dev#53
@goodboy goodboy force-pushed the comprehensible_hook_call_error branch from e2fa34b to 7748ba0 Compare August 24, 2017 15:07
@RonnyPfannschmidt
Copy link
Member

well done, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants