Is there a class under typingthat behaves like mixin?
for instance
from typing import Union
class A:
pass
class B:
pass
class C:
pass
class D(A, B, C):
pass
def f(ab: Union[A, B]):
pass
def f(ab: Mixin[A, B]):
pass
f(D())
note how Dis an instance Aand B, but also C. This would be a too big restriction for f(as it fdoes not require C), and therefore the parameter is abnot necessarily of type D, butMixin[A, B]
If the module typingdoes not provide any option, is there anything more elegant than creating my own class AB(A, B)?
source
share