__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

Comments

Projects
None yet
3 participants
@alexsydell

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 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 in 198478f Apr 14, 2016

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