lisa.utils: Fix PartialInit param binding
FIX Do not include the default value of parameters when checking when binding the kwargs to signature. This is important in cases like that: class Base: def foo(a, b=1): pass @kwargs_forwarded_to(foo) def bar(self, *args, **kwargs): return self.foo(*args, **kwargs) class Derived(Base): def foo(a): pass In this scenario, calling Derived.bar() must not call Derived.foo() with b=1, because Derived.foo does not accept this parameter. This is particularly important as this pattern is typically used to provide a base class with dynamic behavior based on e.g. callbacks, and derived classes that specialize by setting the callback "in stone". This pattern does break Liskov substitution principle, but is nonetheless usually not an issue as long as foo() is somewhat private, and is only used by the user in a monomorphic context.
Loading
Please register or sign in to comment