Skip to content

Commit 5deb645

Browse files
committed
Remove manual kwargs-only check in call
Fix #350.
1 parent 172ca9f commit 5deb645

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/pluggy/_hooks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,7 @@ def _verify_all_args_are_provided(self, kwargs: Mapping[str, object]) -> None:
381381
)
382382
break
383383

384-
def __call__(self, *args: object, **kwargs: object) -> Any:
385-
if args:
386-
raise TypeError("hook calling supports only keyword arguments")
384+
def __call__(self, **kwargs: object) -> Any:
387385
assert (
388386
not self.is_historic()
389387
), "Cannot directly call a historic hook - use call_historic instead."

testing/test_invocations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def hello(self, arg):
3333

3434
pm.add_hookspecs(Api)
3535
with pytest.raises(TypeError) as exc:
36-
pm.hook.hello(3)
36+
pm.hook.hello(3) # type: ignore[call-arg]
3737

38-
comprehensible = "hook calling supports only keyword arguments"
39-
assert comprehensible in str(exc.value)
38+
message = "__call__() takes 1 positional argument but 2 were given"
39+
assert message in str(exc.value)
4040

4141

4242
def test_opt_in_args(pm: PluginManager) -> None:

0 commit comments

Comments
 (0)