forked from VimPlug/jedi
Merge branch 'master' into fix-nested-tuple-argument
This commit is contained in:
@@ -99,7 +99,7 @@ class DefineGenericBase(LazyValueWrapper):
|
||||
for generic_set in self.get_generics():
|
||||
values = NO_VALUES
|
||||
for generic in generic_set:
|
||||
if isinstance(generic, (GenericClass, TypeVar)):
|
||||
if isinstance(generic, (DefineGenericBase, TypeVar)):
|
||||
result = generic.define_generics(type_var_dict)
|
||||
values |= result
|
||||
if result != ValueSet({generic}):
|
||||
|
||||
@@ -12,6 +12,8 @@ from jedi.inference.value import ModuleValue
|
||||
|
||||
_jedi_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
TYPESHED_PATH = os.path.join(_jedi_path, 'third_party', 'typeshed')
|
||||
DJANGO_INIT_PATH = os.path.join(_jedi_path, 'third_party', 'django-stubs',
|
||||
'django-stubs', '__init__.pyi')
|
||||
|
||||
_IMPORT_MAP = dict(
|
||||
_collections='collections',
|
||||
@@ -173,6 +175,13 @@ def _try_to_load_stub(inference_state, import_names, python_value_set,
|
||||
)
|
||||
if m is not None:
|
||||
return m
|
||||
if import_names[0] == 'django':
|
||||
return _try_to_load_stub_from_file(
|
||||
inference_state,
|
||||
python_value_set,
|
||||
file_io=FileIO(DJANGO_INIT_PATH),
|
||||
import_names=import_names,
|
||||
)
|
||||
|
||||
# 2. Try to load pyi files next to py files.
|
||||
for c in python_value_set:
|
||||
|
||||
@@ -226,9 +226,24 @@ class TypingClassValueWithIndex(_TypingClassMixin, TypingValueWithIndex):
|
||||
|
||||
elif annotation_name == 'Callable':
|
||||
if len(annotation_generics) == 2:
|
||||
return annotation_generics[1].infer_type_vars(
|
||||
value_set.execute_annotation(),
|
||||
)
|
||||
if is_class_value:
|
||||
# This only applies if we are comparing something like
|
||||
# List[Callable[..., T]] with Iterable[Callable[..., T]].
|
||||
# First, Jedi tries to match List/Iterable. After that we
|
||||
# will land here, because is_class_value will be True at
|
||||
# that point. Obviously we also compare below that both
|
||||
# sides are `Callable`.
|
||||
for element in value_set:
|
||||
element_name = element.py__name__()
|
||||
if element_name == 'Callable':
|
||||
merge_type_var_dicts(
|
||||
type_var_dict,
|
||||
merge_pairwise_generics(self, element),
|
||||
)
|
||||
else:
|
||||
return annotation_generics[1].infer_type_vars(
|
||||
value_set.execute_annotation(),
|
||||
)
|
||||
|
||||
elif annotation_name == 'Tuple':
|
||||
tuple_annotation = self.get_annotated_class_object()
|
||||
@@ -421,6 +436,10 @@ class NewType(Value):
|
||||
self._type_value_set = type_value_set
|
||||
self.tree_node = tree_node
|
||||
|
||||
def py__class__(self):
|
||||
c, = self._type_value_set.py__class__()
|
||||
return c
|
||||
|
||||
def py__call__(self, arguments):
|
||||
return self._type_value_set.execute_annotation()
|
||||
|
||||
|
||||
@@ -192,13 +192,17 @@ class Sequence(LazyAttributeOverwrite, IterableMixin):
|
||||
def _get_generics(self):
|
||||
return (self.merge_types_of_iterate().py__class__(),)
|
||||
|
||||
@inference_state_method_cache(default=())
|
||||
def _cached_generics(self):
|
||||
return self._get_generics()
|
||||
|
||||
def _get_wrapped_value(self):
|
||||
from jedi.inference.gradual.base import GenericClass
|
||||
from jedi.inference.gradual.generics import TupleGenericManager
|
||||
klass = compiled.builtin_from_name(self.inference_state, self.array_type)
|
||||
c, = GenericClass(
|
||||
klass,
|
||||
TupleGenericManager(self._get_generics())
|
||||
TupleGenericManager(self._cached_generics())
|
||||
).execute_annotation()
|
||||
return c
|
||||
|
||||
|
||||
@@ -186,11 +186,12 @@ class ClassMixin(object):
|
||||
mro.append(cls_new)
|
||||
yield cls_new
|
||||
|
||||
def get_filters(self, origin_scope=None, is_instance=False):
|
||||
metaclasses = self.get_metaclasses()
|
||||
if metaclasses:
|
||||
for f in self.get_metaclass_filters(metaclasses):
|
||||
yield f
|
||||
def get_filters(self, origin_scope=None, is_instance=False, include_metaclasses=True):
|
||||
if include_metaclasses:
|
||||
metaclasses = self.get_metaclasses()
|
||||
if metaclasses:
|
||||
for f in self.get_metaclass_filters(metaclasses):
|
||||
yield f
|
||||
|
||||
for cls in self.py__mro__():
|
||||
if cls.is_compiled():
|
||||
|
||||
Reference in New Issue
Block a user