mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Do more comparisons in the subprocess
This commit is contained in:
@@ -93,7 +93,7 @@ class Context(BaseContext):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if type(index) not in (float, int, str, unicode, slice):
|
||||
if type(index) not in (float, int, str, unicode, slice, bytes):
|
||||
# If the index is not clearly defined, we have to get all the
|
||||
# possiblities.
|
||||
if isinstance(self, AbstractIterable) and self.array_type == 'dict':
|
||||
|
||||
@@ -22,6 +22,7 @@ It is important to note that:
|
||||
"""
|
||||
from jedi import debug
|
||||
from jedi import settings
|
||||
from jedi._compatibility import force_unicode
|
||||
from jedi.evaluate import compiled
|
||||
from jedi.evaluate import analysis
|
||||
from jedi.evaluate import recursion
|
||||
@@ -298,10 +299,11 @@ class SequenceLiteralContext(ArrayMixin, AbstractIterable):
|
||||
def py__getitem__(self, index):
|
||||
"""Here the index is an int/str. Raises IndexError/KeyError."""
|
||||
if self.array_type == 'dict':
|
||||
compiled_obj_index = compiled.create_simple_object(self.evaluator, index)
|
||||
for key, value in self._items():
|
||||
for k in self._defining_context.eval_node(key):
|
||||
if isinstance(k, compiled.CompiledObject) \
|
||||
and index == k.get_safe_value(default=None):
|
||||
and k.execute_operation(compiled_obj_index, '==').get_safe_value():
|
||||
return self._defining_context.eval_node(value)
|
||||
raise KeyError('No key found in dictionary %s.' % self)
|
||||
|
||||
|
||||
@@ -190,7 +190,11 @@ def is_compiled(context):
|
||||
|
||||
|
||||
def is_string(context):
|
||||
return is_compiled(context) and isinstance(context.get_safe_value(default=None), (str, unicode))
|
||||
if context.evaluator.environment.version_info.major == 2:
|
||||
str_classes = (str, unicode, bytes)
|
||||
else:
|
||||
str_classes = (str,)
|
||||
return is_compiled(context) and isinstance(context.get_safe_value(default=None), str_classes)
|
||||
|
||||
|
||||
def is_literal(context):
|
||||
|
||||
Reference in New Issue
Block a user