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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pluggy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ 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("hook calling supports only keyword arguments")
assert not self.is_historic()
if self.argnames:
notincall = set(self.argnames) - set(['__multicall__']) - set(
Expand Down
6 changes: 5 additions & 1 deletion testing/test_hookrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def hello(self, arg):
"api hook 1"

pm.add_hookspecs(Api)
pytest.raises(TypeError, lambda: pm.hook.hello(3))
with pytest.raises(TypeError) as exc:
pm.hook.hello(3)

comprehensible = "hook calling supports only keyword arguments"
assert comprehensible in str(exc.value)


def test_firstresult_definition(pm):
Expand Down