forked from VimPlug/jedi
Rename AnnotatedClass to GenericClass
This commit is contained in:
@@ -333,7 +333,7 @@ class FunctionExecutionContext(TreeContext):
|
||||
evaluator = self.evaluator
|
||||
is_coroutine = self.tree_node.parent.type in ('async_stmt', 'async_funcdef')
|
||||
is_generator = bool(get_yield_exprs(evaluator, self.tree_node))
|
||||
from jedi.evaluate.gradual.typing import AnnotatedSubClass
|
||||
from jedi.evaluate.gradual.typing import GenericClass
|
||||
|
||||
if is_coroutine:
|
||||
if is_generator:
|
||||
@@ -347,7 +347,7 @@ class FunctionExecutionContext(TreeContext):
|
||||
generics = (yield_contexts.py__class__(), NO_CONTEXTS)
|
||||
return ContextSet(
|
||||
# In Python 3.6 AsyncGenerator is still a class.
|
||||
AnnotatedSubClass(c, generics)
|
||||
GenericClass(c, generics)
|
||||
for c in async_generator_classes
|
||||
).execute_annotation()
|
||||
else:
|
||||
@@ -358,7 +358,7 @@ class FunctionExecutionContext(TreeContext):
|
||||
# Only the first generic is relevant.
|
||||
generics = (return_contexts.py__class__(), NO_CONTEXTS, NO_CONTEXTS)
|
||||
return ContextSet(
|
||||
AnnotatedSubClass(c, generics) for c in async_classes
|
||||
GenericClass(c, generics) for c in async_classes
|
||||
).execute_annotation()
|
||||
else:
|
||||
if is_generator:
|
||||
|
||||
@@ -208,10 +208,10 @@ class Sequence(BuiltinOverwrite, IterableMixin):
|
||||
|
||||
@memoize_method
|
||||
def get_object(self):
|
||||
from jedi.evaluate.gradual.typing import AnnotatedSubClass
|
||||
from jedi.evaluate.gradual.typing import GenericClass
|
||||
klass = compiled.builtin_from_name(self.evaluator, self.array_type)
|
||||
# TODO is this execute annotation wrong? it returns a context set?!
|
||||
return AnnotatedSubClass(klass, self._get_generics()).execute_annotation()
|
||||
return GenericClass(klass, self._get_generics()).execute_annotation()
|
||||
|
||||
def py__bool__(self):
|
||||
return None # We don't know the length, because of appends.
|
||||
|
||||
@@ -243,11 +243,11 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBa
|
||||
)]
|
||||
|
||||
def py__getitem__(self, index_context_set, contextualized_node):
|
||||
from jedi.evaluate.gradual.typing import AnnotatedClass
|
||||
from jedi.evaluate.gradual.typing import LazyGenericClass
|
||||
if not index_context_set:
|
||||
return ContextSet([self])
|
||||
return ContextSet(
|
||||
AnnotatedClass(
|
||||
LazyGenericClass(
|
||||
self,
|
||||
index_context,
|
||||
context_of_index=contextualized_node.context,
|
||||
@@ -256,7 +256,7 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBa
|
||||
)
|
||||
|
||||
def define_generics(self, type_var_dict):
|
||||
from jedi.evaluate.gradual.typing import AnnotatedSubClass
|
||||
from jedi.evaluate.gradual.typing import GenericClass
|
||||
|
||||
def remap_type_vars():
|
||||
"""
|
||||
@@ -272,7 +272,7 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBa
|
||||
yield type_var_dict.get(type_var.py__name__(), NO_CONTEXTS)
|
||||
|
||||
if type_var_dict:
|
||||
return AnnotatedSubClass(
|
||||
return GenericClass(
|
||||
self,
|
||||
generics=tuple(remap_type_vars())
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ from parso import ParserSyntaxError, parse
|
||||
from jedi._compatibility import force_unicode
|
||||
from jedi.evaluate.cache import evaluator_method_cache
|
||||
from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS
|
||||
from jedi.evaluate.gradual.typing import TypeVar, AnnotatedClass, \
|
||||
from jedi.evaluate.gradual.typing import TypeVar, LazyGenericClass, \
|
||||
AbstractAnnotatedClass
|
||||
from jedi.evaluate.helpers import is_string
|
||||
from jedi import debug
|
||||
@@ -274,7 +274,7 @@ def _infer_type_vars(annotation_context, context_set):
|
||||
type_var_dict = {}
|
||||
if isinstance(annotation_context, TypeVar):
|
||||
return {annotation_context.py__name__(): context_set.py__class__()}
|
||||
elif isinstance(annotation_context, AnnotatedClass):
|
||||
elif isinstance(annotation_context, LazyGenericClass):
|
||||
name = annotation_context.py__name__()
|
||||
if name == 'Iterable':
|
||||
given = annotation_context.get_generics()
|
||||
|
||||
@@ -588,7 +588,7 @@ class AbstractAnnotatedClass(ClassMixin, ContextWrapper):
|
||||
# cached results.
|
||||
return self
|
||||
|
||||
return AnnotatedSubClass(
|
||||
return GenericClass(
|
||||
self._wrapped_context,
|
||||
generics=tuple(new_generics)
|
||||
)
|
||||
@@ -606,9 +606,9 @@ class AbstractAnnotatedClass(ClassMixin, ContextWrapper):
|
||||
yield LazyAnnotatedBaseClass(self, base)
|
||||
|
||||
|
||||
class AnnotatedClass(AbstractAnnotatedClass):
|
||||
class LazyGenericClass(AbstractAnnotatedClass):
|
||||
def __init__(self, class_context, index_context, context_of_index):
|
||||
super(AnnotatedClass, self).__init__(class_context)
|
||||
super(LazyGenericClass, self).__init__(class_context)
|
||||
self._index_context = index_context
|
||||
self._context_of_index = context_of_index
|
||||
|
||||
@@ -617,9 +617,9 @@ class AnnotatedClass(AbstractAnnotatedClass):
|
||||
return list(_iter_over_arguments(self._index_context, self._context_of_index))
|
||||
|
||||
|
||||
class AnnotatedSubClass(AbstractAnnotatedClass):
|
||||
class GenericClass(AbstractAnnotatedClass):
|
||||
def __init__(self, class_context, generics):
|
||||
super(AnnotatedSubClass, self).__init__(class_context)
|
||||
super(GenericClass, self).__init__(class_context)
|
||||
self._generics = generics
|
||||
|
||||
def get_generics(self):
|
||||
@@ -636,7 +636,7 @@ class LazyAnnotatedBaseClass(object):
|
||||
for base in self._lazy_base_class.infer():
|
||||
if isinstance(base, AbstractAnnotatedClass):
|
||||
# Here we have to recalculate the given types.
|
||||
yield AnnotatedSubClass.create_cached(
|
||||
yield GenericClass.create_cached(
|
||||
base.evaluator,
|
||||
base._wrapped_context,
|
||||
tuple(self._remap_type_vars(base)),
|
||||
|
||||
Reference in New Issue
Block a user