Skip to content

Order dependent bug in fine-grained generic alias handling #4903

Closed

Description

@msullivan

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"

Activity

  1. ilevkivskyi commented on Apr 13, 2018

    @ilevkivskyi
    Member

    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 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.

  2. msullivan commented on Apr 13, 2018

    @msullivan
    CollaboratorAuthor

    Would it be possible to create dependencies like:

    <a.A.__init__> -> <d.B.__init__>
    <d.B.__init__> -> x
    

    ?

  3. self-assigned this
    on Apr 22, 2018
  4. ilevkivskyi commented on Apr 22, 2018

    @ilevkivskyi
    Member

    I will take a look at this. There might be something more subtle happening.

  5. JukkaL commented on Nov 1, 2018

    @JukkaL
    Collaborator

    This was fixed by #5221.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions