Skip to content
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

__init__ of subclass of a Generic class uses the generic type instead of the specified one #1246

Closed
alexsydell opened this issue Feb 26, 2016 · 0 comments
Assignees
Labels
bug mypy got something wrong

Comments

@alexsydell
Copy link

Code to repro:

#!/usr/bin/env python
from typing import Generic, TypeVar

T = TypeVar("T")

class Test(Generic[T]):

    def __init__(self, a):
        # type: (T) -> None
        self.a = a

class StrTest(Test[str]):
    pass

s = StrTest("str1")

I would expect there to be no error here, but mypy outputs the following:

test.py:15: error: Argument 1 to "StrTest" has incompatible type "str"; expected "T"
@ddfisher ddfisher added the bug mypy got something wrong label Mar 1, 2016
@ddfisher ddfisher added this to the 0.3.2 milestone Mar 1, 2016
@rwbarton rwbarton self-assigned this Apr 12, 2016
rwbarton added a commit to rwbarton/mypy that referenced this issue Apr 13, 2016
rwbarton added a commit to rwbarton/mypy that referenced this issue Apr 13, 2016
@JukkaL JukkaL closed this as completed in 198478f Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants