Skip to content

Why pluggy ignore hookimpl kwargsnames? #522

Open
@noklam

Description

@noklam

Description

I try to set default argument for a hook and find it does not work.

class SomeClass:
  @hookimpl
  def my_func(self, a=1):
     ...

It seems like if I use a kwargs, pluggy will ignore this argument and won't call it anymore. I can see that HookImpl stores both kwargsnames and argnames but only argnames are called. Is this intentional or bug? I try to search in the docs but couldn't find anything related.

Context

for hook_impl in reversed(hook_impls):
try:
args = [caller_kwargs[argname] for argname in hook_impl.argnames]

In docs, it said:

naming markers: HookSpecMarker and HookImplMarker must be initialized with the name of the host project (the name parameter in setup()) - so eggsample in our case.

But it never mentioned keywords arguments cannot be used.

p.s. I did a bit more digging, it seems that kwargnames is never used anywhere in the source code other than saving it as an attribute.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions