Open
Description
Sorry if this has been discussed before.
Currently, the draft PEP says that the Intersection[...]
element order for the intersection does not matter, and create overloads for the intersection types. However the file under notes.txt
says that the intersection of class types should follow the MRO, which relies on the order the classes are provided.
In general, this means that if the order and @overload
ing of the attributes is how the specification should work, the way the typing works is different from multiple inheritance actually works in Python. Given the example below:
class A:
def __init__(self, a: int):
self.a = a
class B:
def __init__(self, a: str, b: int):
self.a = a
self.b = b
class AB(A, B):
# Will use A's __init__ via MRO
T_AB = A & B # Very different assumptions to the actual multiple inheritance case
# Equivalent to:
class T_AB:
@overload
def __init__(self, a: int)
...
@overload
def __init__(self, a: str, b: int)
...
Means that the type checker will make assumptions on code interfaces that won't exist during run time as using the second overload will result in an error.
Metadata
Metadata
Assignees
Labels
No labels