I am trying to get proper auto-completion for a decorated class. The Problem is that the decorator doesn't just change the class but it creates and returns a new one, derived from the decorated class and another class.
In other words, I need to annotate a functions return value as the parameter and a base class.
Here a simplified example:
class A:
def func_a(self): pass
def decorator(cls): # what type hint comes here?
class Result(cls, A):
pass
return Result
@decorator
class B:
def func_b(self): pass
obj = B()
obj.func_a()
obj.func_b()
Here my IDE detects func_a but not func_b.
In TypeScript the solution would be something like
decorator<T>(cls: T): A & T
It seems python doesn't have this & operator for type hints. Which annotation do I use? Or is it just not possible?