You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Order dependent bug in fine-grained generic alias handling #4903
Renaming b to d in testAliasFineInitGenericMod produces the following test, which fails, producing no errors:
[case testAliasFineInitGenericMod2]
import c
[file a.py]
from typing import Generic, TypeVar
T = TypeVar('T')
S = TypeVar('S')
class A(Generic[T, S]):
def __init__(self, x: T) -> None:
pass
[file a.py.2]
from typing import Generic, TypeVar
T = TypeVar('T')
S = TypeVar('S')
class A(Generic[T, S]):
def __init__(self, x: S) -> None:
pass
[file d.py]
import a
B = a.A[int, str]
[file c.py]
from d import B
B(int())
[out]
==
c.py:2: error: Argument 1 has incompatible type "int"; expected "str"
I actually was afraid this will trigger at some point. The problem is that from the point of view of the snapshot diff, after update B points to exactly the same type. A possible solution is to include signatures of __init__ and __new__ in alias snapshot, but this may cause some unnecessary re-checks, because aliases are rarely used in runtime context. (On the positive side some existing deps will become redundant if we do this). @JukkaL what do you think? This seems to me similar to the problem of @abstractmethod where performance and correctness are also not on the same side.
Activity
ilevkivskyi commentedon Apr 13, 2018
Thanks for finding this!
I actually was afraid this will trigger at some point. The problem is that from the point of view of the snapshot diff, after update
Bpoints to exactly the same type. A possible solution is to include signatures of__init__and__new__in alias snapshot, but this may cause some unnecessary re-checks, because aliases are rarely used in runtime context. (On the positive side some existing deps will become redundant if we do this). @JukkaL what do you think? This seems to me similar to the problem of@abstractmethodwhere performance and correctness are also not on the same side.msullivan commentedon Apr 13, 2018
Would it be possible to create dependencies like:
?
ilevkivskyi commentedon Apr 22, 2018
I will take a look at this. There might be something more subtle happening.
JukkaL commentedon Nov 1, 2018
This was fixed by #5221.