Fix itemgetter for tuples

This commit is contained in:
Dave Halter
2018-10-05 10:51:52 +02:00
parent 1b8c87215d
commit 380f0ac404
2 changed files with 11 additions and 4 deletions

View File

@@ -26,7 +26,8 @@ from jedi.evaluate.context import ClassContext, ModuleContext, \
FunctionExecutionContext FunctionExecutionContext
from jedi.evaluate.context.klass import py__mro__ from jedi.evaluate.context.klass import py__mro__
from jedi.evaluate.context import iterable from jedi.evaluate.context import iterable
from jedi.evaluate.lazy_context import LazyTreeContext, LazyKnownContext from jedi.evaluate.lazy_context import LazyTreeContext, LazyKnownContext, \
LazyKnownContexts
from jedi.evaluate.syntax_tree import is_string from jedi.evaluate.syntax_tree import is_string
# Now this is all part of fake tuples in Jedi. However super doesn't work on # Now this is all part of fake tuples in Jedi. However super doesn't work on
@@ -475,8 +476,14 @@ class ItemGetterCallable(object):
# TODO we need to add the contextualized context. # TODO we need to add the contextualized context.
context_set |= item_context_set.get_item(lazy_contexts[0].infer(), None) context_set |= item_context_set.get_item(lazy_contexts[0].infer(), None)
else: else:
return NO_CONTEXTS context_set |= ContextSet([iterable.FakeSequence(
raise NotImplementedError self.evaluator,
'list',
[
LazyKnownContexts(item_context_set.get_item(lazy_context.infer(), None))
for lazy_context in lazy_contexts
],
)])
return context_set return context_set

View File

@@ -259,7 +259,7 @@ g = operator.itemgetter(1, 2)
x1, x2 = g([1, 1.0, '']) x1, x2 = g([1, 1.0, ''])
#? float() #? float()
x1 x1
#? float() #? str()
x2 x2
x1, x2 = g([1, '']) x1, x2 = g([1, ''])