Skip to content

Register pre-defined hook with arguments #35

@timlehr

Description

@timlehr

Hi Rotem,

Thanks for developing Gossip. I love it!
I'm currently using it as part of a framework I'm writing, so I'm pre-defining a lot of hooks I use in different places. I always store the hook object and use it directly for registration (to have the hook name defined in only one place), but I'm hitting a wall when using arguments with these objects. I'm using strict groups.

# Works fine
myhook = gossip.define("mygroup.testhook", arg_names=["some_arg"])

@myhook.register
def some_function(some_arg):
    pass
# Does not work: 
myhook = gossip.define("mygroup.testhook", arg_names=["some_arg"], tags=["test"])

@myhook.register(tags=["test"])
def some_function(some_arg):
    pass

I always end up with the following
TypeError: register() takes at least 2 arguments (2 given)

Do I need to wrap the register() call to get the functionality I want?

Cheers!
Tim

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