from obsub import event
class Foo(object):
@event
def bar(this, self):
pass
@event
def baz(self, instance):
pass
foo = Foo()
foo.bar(1) # works fine
foo.bar(self=1) # TypeError
Foo.baz(foo, 1) # works fine
Foo.baz(foo, instance=1) # TypeError
The reason for this behaviour is obvious: obsub uses normal python arguments named instance and self in the wrapper functions, because python syntax doesn't allow for positional-only parameters. The fix is easy: make the signature of those functions (*args, **kwargs) and extract the self/instance parameter as the first parameter from *args.
Consider the following example:
The reason for this behaviour is obvious: obsub uses normal python arguments named
instance
andself
in the wrapper functions, because python syntax doesn't allow for positional-only parameters. The fix is easy: make the signature of those functions(*args, **kwargs)
and extract theself
/instance
parameter as the first parameter from*args
.