Skip to content

False positive error "incompatible type" calling super() on a generic class with TypeVar constraints #14774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
leandro-lucarella-frequenz opened this issue Feb 24, 2023 · 0 comments

Comments

@leandro-lucarella-frequenz
Copy link

leandro-lucarella-frequenz commented Feb 24, 2023

Reduced test case (mypy-playground):

from typing import Generic, TypeVar

T = TypeVar("T", float, int)


class C(Generic[T]):
    def __init__(self, i: T) -> None:
        self.i: T = i


class B(C[T]):
    def __init__(self, i: T) -> None:
        super().__init__(i)
main.py: note: In member "__init__" of class "B":
main.py:13:26: error: Argument 1 to "__init__" of "C" has incompatible type "float"; expected "T"  [arg-type]
main.py:13:26: error: Argument 1 to "__init__" of "C" has incompatible type "int"; expected "T"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Originally posted by @leandro-lucarella-frequenz in #13566 (comment) (this is a very similar issue but not exactly the same)

leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Feb 24, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Feb 24, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Feb 24, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Feb 27, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Feb 28, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Mar 1, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
leandro-lucarella-frequenz pushed a commit to llucax/frequenz-sdk-python that referenced this issue Mar 2, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
matthias-wende-frequenz pushed a commit to matthias-wende-frequenz/frequenz-sdk-python that referenced this issue Apr 13, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
matthias-wende-frequenz pushed a commit to matthias-wende-frequenz/frequenz-sdk-python that referenced this issue Apr 26, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
matthias-wende-frequenz pushed a commit to matthias-wende-frequenz/frequenz-sdk-python that referenced this issue Jul 6, 2023
See python/mypy#14774 for more details.

Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant