mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Change some TypeVar base classes
This commit is contained in:
@@ -65,7 +65,7 @@ class _BaseTypingContext(Context):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return ContextName(self, self._name)
|
return ContextName(self, self._name.tree_name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(%s)' % (self.__class__.__name__, self._name.string_name)
|
return '%s(%s)' % (self.__class__.__name__, self._name.string_name)
|
||||||
|
|||||||
@@ -311,6 +311,9 @@ TYPE_VAR = typing.TypeVar('TYPE_VAR')
|
|||||||
# TODO there should at least be some results.
|
# TODO there should at least be some results.
|
||||||
#? []
|
#? []
|
||||||
TYPE_VAR.
|
TYPE_VAR.
|
||||||
|
#! ["TYPE_VAR = typing.TypeVar('TYPE_VAR')"]
|
||||||
|
TYPE_VAR
|
||||||
|
|
||||||
|
|
||||||
class WithTypeVar(typing.Generic[TYPE_VAR]):
|
class WithTypeVar(typing.Generic[TYPE_VAR]):
|
||||||
def lala(self) -> TYPE_VAR:
|
def lala(self) -> TYPE_VAR:
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from jedi.plugins import typeshed
|
from jedi.plugins import typeshed
|
||||||
from jedi.evaluate.context import TreeInstance, BoundMethod, CompiledInstance
|
from jedi.evaluate.context import TreeInstance, BoundMethod, CompiledInstance
|
||||||
from parso.utils import PythonVersionInfo
|
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')
|
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 test_get_typeshed_directories():
|
||||||
def get_dirs(version_info):
|
def get_dirs(version_info):
|
||||||
return {
|
return {
|
||||||
@@ -125,3 +120,9 @@ def test_math(Script):
|
|||||||
assert def_.name == 'float'
|
assert def_.name == 'float'
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert 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()'
|
||||||
|
|||||||
Reference in New Issue
Block a user