By having get_annotated_class_object for Tuple/Callable, some details are not necessary anymore

This commit is contained in:
Dave Halter
2020-05-10 02:52:42 +02:00
parent c2d1da09cb
commit 42963a0e03
3 changed files with 8 additions and 6 deletions

View File

@@ -350,7 +350,7 @@ def merge_pairwise_generics(annotation_value, annotated_argument_class):
type_var_dict = {}
if not isinstance(annotated_argument_class, (DefineGenericBase, BaseTypingInstance)):
if not isinstance(annotated_argument_class, (DefineGenericBase)):
return type_var_dict
annotation_generics = annotation_value.get_generics()

View File

@@ -389,6 +389,9 @@ class BaseTypingInstance(LazyValueWrapper):
def py__class__(self):
return self._class_value
def get_annotated_class_object(self):
return self._class_value
@property
def name(self):
return ValueName(self, self._tree_name)
@@ -400,3 +403,6 @@ class BaseTypingInstance(LazyValueWrapper):
def _get_wrapped_value(self):
object_, = builtin_from_name(self.inference_state, u'object').execute_annotation()
return object_
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self._generics_manager)

View File

@@ -316,7 +316,6 @@ class Tuple(BaseTypingInstance):
def infer_type_vars(self, value_set):
# Circular
from jedi.inference.gradual.annotation import merge_pairwise_generics, merge_type_var_dicts
from jedi.inference.gradual.base import GenericClass
value_set = value_set.filter(
lambda x: x.py__name__().lower() == 'tuple',
@@ -345,11 +344,8 @@ class Tuple(BaseTypingInstance):
# above is not 100% correct, so just catch the remaining
# cases here.
continue
else:
py_class = method()
if not isinstance(py_class, GenericClass):
py_class = element
py_class = method()
merge_type_var_dicts(
type_var_dict,
merge_pairwise_generics(self, py_class),