Skip to content

Quick fix for selftype+super #2362

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

Merged
merged 1 commit into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from mypy.checkstrformat import StringFormatterChecker
from mypy.expandtype import expand_type
from mypy.util import split_module_names
from mypy.semanal import fill_typevars

from mypy import experiments

Expand Down Expand Up @@ -1609,7 +1610,7 @@ def analyze_super(self, e: SuperExpr, is_lvalue: bool) -> Type:
self.chk.fail('super() requires at least on positional argument', e)
return AnyType()
declared_self = args[0].variable.type
return analyze_member_access(name=e.name, typ=declared_self, node=e,
return analyze_member_access(name=e.name, typ=fill_typevars(e.info), node=e,
is_lvalue=False, is_super=True, is_operator=False,
builtin_type=self.named_type,
not_ready_callback=self.not_ready_callback,
Expand Down
12 changes: 12 additions & 0 deletions test-data/unit/check-selftype.test
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,15 @@ def make(cls: Type[T]) -> T:
return cls.new()

[builtins fixtures/classmethod.pyi]

[case testSelfTypeGeneric]
from typing import TypeVar

T = TypeVar('T', int, str)

class A:
pass

class B(A):
def __init__(self, arg: T) -> None:
super(B, self).__init__()