鉴于我有一个类从其他两个类继承:
class Mother:
pass
class Father:
pass
class Child(Mother, Father):
pass
还有一个 Mixin 类提供工厂方法Child:
class FactoryMixin:
def make(self: (FactoryMixin and Child)) -> (FactoryMixin and Child):
return self.__class__()
表达这些类的联合的正确类型提示是(FactoryMixin and Child)什么?请不要建议,typing.Union因为Union[A, B]意味着A or B, not A and B (来源)。这是一个最小的例子,实际情况要复杂得多。