diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index ece3afb4..3d01a841 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -65,7 +65,7 @@ class _BaseTypingContext(Context): @property def name(self): - return ContextName(self, self._name) + return ContextName(self, self._name.tree_name) def __repr__(self): return '%s(%s)' % (self.__class__.__name__, self._name.string_name) diff --git a/test/completion/pep0484_typing.py b/test/completion/pep0484_typing.py index 9b191187..76cacb0a 100644 --- a/test/completion/pep0484_typing.py +++ b/test/completion/pep0484_typing.py @@ -311,6 +311,9 @@ TYPE_VAR = typing.TypeVar('TYPE_VAR') # TODO there should at least be some results. #? [] TYPE_VAR. +#! ["TYPE_VAR = typing.TypeVar('TYPE_VAR')"] +TYPE_VAR + class WithTypeVar(typing.Generic[TYPE_VAR]): def lala(self) -> TYPE_VAR: diff --git a/test/test_plugin/test_stub.py b/test/test_plugin/test_stub.py index 59a111c9..1f70a5e7 100644 --- a/test/test_plugin/test_stub.py +++ b/test/test_plugin/test_stub.py @@ -1,7 +1,5 @@ import os -import pytest - from jedi.plugins import typeshed from jedi.evaluate.context import TreeInstance, BoundMethod, CompiledInstance from parso.utils import PythonVersionInfo @@ -10,9 +8,6 @@ from jedi.evaluate.filters import TreeNameDefinition TYPESHED_PYTHON3 = os.path.join(typeshed._TYPESHED_PATH, 'stdlib', '3') -pytestmark = pytest.mark.skip(reason="For now ignore stub tests") - - def test_get_typeshed_directories(): def get_dirs(version_info): return { @@ -125,3 +120,9 @@ def test_math(Script): assert def_.name == 'float' context = def_._name._context assert context + + +def test_type_var(Script): + def_, = Script('import typing; T = typing.TypeVar("T1")').goto_definitions() + assert def_.name == 'TypeVar' + assert def_.description == 'TypeVar = object()'