Skip to content
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
2 changes: 1 addition & 1 deletion src/pluggy/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
)

if hook.spec.warn_on_impl_args:
for hookimpl_argname in hookimpl.argnames:
for hookimpl_argname in hookimpl.argnames + hookimpl.kwargnames:
argname_warning = hook.spec.warn_on_impl_args.get(hookimpl_argname)
if argname_warning is not None:
_warn_for_function(argname_warning, hookimpl.function)
Expand Down
24 changes: 24 additions & 0 deletions testing/test_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ def foo(self, old2, old1, new):
assert record2.lineno == Plugin.foo.__code__.co_firstlineno


def test_warn_when_deprecated_args_with_defaults_specified() -> None:
warning = DeprecationWarning("old is deprecated")

class Spec:
@hookspec(warn_on_impl_args={"old": warning})
def foo(self, old=None, new=None):
raise NotImplementedError()

class Plugin:
@hookimpl
def foo(self, old=None, new=None):
raise NotImplementedError()

pm = PluginManager(hookspec.project_name)
pm.add_hookspecs(Spec)

with pytest.warns(DeprecationWarning) as records:
pm.register(Plugin())
(record,) = records
assert record.message is warning
assert record.filename == Plugin.foo.__code__.co_filename
assert record.lineno == Plugin.foo.__code__.co_firstlineno


def test_plugin_getattr_raises_errors() -> None:
"""Pluggy must be able to handle plugins which raise weird exceptions
when getattr() gets called (#11).
Expand Down
Loading