Skip to content

Commit

Permalink
Raise explicit error when impl called with pos args
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tyler Goodlet committed Aug 23, 2017
1 parent 6689c91 commit ce2104b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pluggy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,11 @@ def _add_hookimpl(self, hookimpl):
def __repr__(self):
return "<_HookCaller %r>" % (self.name,)

def __call__(self, **kwargs):
def __call__(self, *args, **kwargs):
if args:
raise TypeError(
"hookimpl takes keyword arguments only".format(self.name)
)
assert not self.is_historic()
if self.argnames:
notincall = set(self.argnames) - set(['__multicall__']) - set(
Expand Down

0 comments on commit ce2104b

Please sign in to comment.