Change some TypeVar base classes

This commit is contained in:
Dave Halter
2018-08-30 10:15:43 +02:00
parent f5f9fc1955
commit 2ec503d6eb
3 changed files with 10 additions and 6 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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()'