Fix an issue with a type var lookups

This commit is contained in:
Dave Halter
2018-08-30 01:10:51 +02:00
parent 28a55386b6
commit bf6974dabb
2 changed files with 14 additions and 1 deletions

View File

@@ -479,7 +479,7 @@ class _AbstractAnnotatedClass(ClassContext):
continue # These are not relevant for this search. continue # These are not relevant for this search.
if node.type == 'atom_expr': if node.type == 'atom_expr':
trailer = node.children[1] trailer = node.children[-1]
if trailer.type == 'trailer' and trailer.children[0] == '[': if trailer.type == 'trailer' and trailer.children[0] == '[':
for subscript_node in self._unpack_subscriptlist(trailer.children[1]): for subscript_node in self._unpack_subscriptlist(trailer.children[1]):
type_var_set = self.parent_context.eval_node(subscript_node) type_var_set = self.parent_context.eval_node(subscript_node)

View File

@@ -305,3 +305,16 @@ from typing import Union as U
def union4(x: U[int, str]): def union4(x: U[int, str]):
#? int() str() #? int() str()
x x
TYPE_VAR = typing.TypeVar('TYPE_VAR')
class WithTypeVar(typing.Generic[TYPE_VAR]):
def lala(self) -> TYPE_VAR:
...
def maaan(p: WithTypeVar[int]):
#? int()
p.lala()