What would be the proper way to type the print_before
function decorator, so that the
wrapped function has the proper type but I can't use the decorator on a class that would not work?
thank you
def print_before(func):
def func_wrapper(self, *args):
self.print_hi()
return func(self, *args)
return func_wrapper
class PrintThings:
def print_hi(self):
print("hi")
@print_before
def add_nums(self, a: int, b: int) -> int:
return a + b
pt = PrintThings()
pt.add_nums(5, 4)
class ShouldNotWork:
@print_before
def add_nums(self, a: int, b: int) -> int:
return a + b
snw = ShouldNotWork()
snw.add_nums(4, 5)