forked from VimPlug/jedi
Make sure tuple behaves similar to Tuple, fixes #2040
This commit is contained in:
@@ -145,6 +145,10 @@ class InferenceState:
|
|||||||
typing_module, = self.import_module(('types',))
|
typing_module, = self.import_module(('types',))
|
||||||
return typing_module
|
return typing_module
|
||||||
|
|
||||||
|
@inference_state_function_cache()
|
||||||
|
def typing_tuple(self):
|
||||||
|
return self.typing_module.py__getattribute__("Tuple")
|
||||||
|
|
||||||
def reset_recursion_limitations(self):
|
def reset_recursion_limitations(self):
|
||||||
self.recursion_detector = recursion.RecursionDetector()
|
self.recursion_detector = recursion.RecursionDetector()
|
||||||
self.execution_recursion_detector = recursion.ExecutionRecursionDetector(self)
|
self.execution_recursion_detector = recursion.ExecutionRecursionDetector(self)
|
||||||
|
|||||||
@@ -909,6 +909,15 @@ class EnumInstance(LazyValueWrapper):
|
|||||||
yield f
|
yield f
|
||||||
|
|
||||||
|
|
||||||
|
# Make sure tuple[...] behaves like Tuple[...]
|
||||||
|
class TupleClassWrapper(ValueWrapper):
|
||||||
|
def py__getitem__(self, index_value_set, contextualized_node):
|
||||||
|
return self.inference_state.typing_tuple().py__getitem__(
|
||||||
|
index_value_set,
|
||||||
|
contextualized_node,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def tree_name_to_values(func):
|
def tree_name_to_values(func):
|
||||||
def wrapper(inference_state, context, tree_name):
|
def wrapper(inference_state, context, tree_name):
|
||||||
if tree_name.value == 'sep' \
|
if tree_name.value == 'sep' \
|
||||||
@@ -916,5 +925,9 @@ def tree_name_to_values(func):
|
|||||||
return ValueSet({
|
return ValueSet({
|
||||||
compiled.create_simple_object(inference_state, os.path.sep),
|
compiled.create_simple_object(inference_state, os.path.sep),
|
||||||
})
|
})
|
||||||
|
if tree_name.value == 'tuple' \
|
||||||
|
and context.is_module() and context.py__name__() == 'builtins':
|
||||||
|
tup, = func(inference_state, context, tree_name)
|
||||||
|
return ValueSet([TupleClassWrapper(tup)])
|
||||||
return func(inference_state, context, tree_name)
|
return func(inference_state, context, tree_name)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user