1
0
forked from VimPlug/jedi

Some more work on the filter merging

This commit is contained in:
Dave Halter
2018-10-05 01:57:34 +02:00
parent f96a14e7f4
commit 65340e6e24
6 changed files with 83 additions and 58 deletions

View File

@@ -18,8 +18,6 @@ from jedi.evaluate.cache import evaluator_as_method_param_cache
class HelperContextMixin:
tree_node = None
@classmethod
@evaluator_as_method_param_cache()
def create_cached(cls, *args, **kwargs):
@@ -62,6 +60,8 @@ class HelperContextMixin:
return False
def is_same_class(self, class2):
if isinstance(class2, ContextWrapper):
class2 = class2._wrapped_context
# Class matching should prefer comparisons that are not this function.
if type(class2).is_same_class != HelperContextMixin.is_same_class:
return class2.is_same_class(self)
@@ -76,6 +76,7 @@ class Context(HelperContextMixin, BaseContext):
"""
To be defined by subclasses.
"""
tree_node = None
@property
def api_type(self):

View File

@@ -373,6 +373,9 @@ class CompiledObjectFilter(AbstractFilter):
def _create_name(self, name):
return self.name_class(self._evaluator, self._compiled_object, name)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self._compiled_object)
docstr_defaults = {
'floating point number': u'float',

View File

@@ -63,6 +63,7 @@ def apply_py__get__(context, base_context):
@evaluator_method_cache(default=())
def py__mro__(context):
try:
# TODO is this really needed?
method = context.py__mro__
except AttributeError:
pass

View File

@@ -26,7 +26,6 @@ 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.context import ClassContext
from jedi.evaluate.context.typing import TypeVar, AnnotatedClass, \
AbstractAnnotatedClass
from jedi.evaluate.helpers import is_string
@@ -232,12 +231,15 @@ def infer_return_types(function_execution_context):
However, the iterator is defined as Iterator[_T_co], which means it has
a different type var name.
"""
if isinstance(context, ClassContext):
try:
func = context.list_type_vars
except AttributeError:
return type_var_dict
else:
return {
to.py__name__(): type_var_dict.get(from_.py__name__(), NO_CONTEXTS)
for from_, to in zip(unknown_type_vars, context.list_type_vars())
for from_, to in zip(unknown_type_vars, func())
}
return type_var_dict
return ContextSet(
ann.define_generics(type_var_dict)