mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-24 17:28:36 +08:00
slices should be ignored in __getitem__ settings (for now)
This commit is contained in:
@@ -109,7 +109,7 @@ class Evaluator(object):
|
|||||||
return f.filter_name(scopes)
|
return f.filter_name(scopes)
|
||||||
return f.find(scopes, resolve_decorator)
|
return f.find(scopes, resolve_decorator)
|
||||||
|
|
||||||
@memoize_default(default=(), evaluator_is_first_arg=True)
|
@memoize_default(default=[], evaluator_is_first_arg=True)
|
||||||
@recursion.recursion_decorator
|
@recursion.recursion_decorator
|
||||||
@debug.increase_indent
|
@debug.increase_indent
|
||||||
def eval_statement(self, stmt, seek_name=None):
|
def eval_statement(self, stmt, seek_name=None):
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ would check whether a flow has the form of ``if isinstance(a, type_or_tuple)``.
|
|||||||
Unfortunately every other thing is being ignored (e.g. a == '' would be easy to
|
Unfortunately every other thing is being ignored (e.g. a == '' would be easy to
|
||||||
check for -> a is a string). There's big potential in these checks.
|
check for -> a is a string). There's big potential in these checks.
|
||||||
"""
|
"""
|
||||||
import copy
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from jedi._compatibility import hasattr, unicode, u, reraise
|
from jedi._compatibility import hasattr, unicode, u, reraise
|
||||||
|
|||||||
@@ -169,6 +169,12 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_index_types(self, indexes=[]):
|
def get_index_types(self, indexes=[]):
|
||||||
|
if any([isinstance(i, iterable.Slice) for i in indexes]):
|
||||||
|
# Slice support in Jedi is very marginal, at the moment, so just
|
||||||
|
# ignore them in case of __getitem__.
|
||||||
|
# TODO support slices in a more general way.
|
||||||
|
indexes = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.execute_subscope_by_name('__getitem__', indexes)
|
return self.execute_subscope_by_name('__getitem__', indexes)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ b = [6,7]
|
|||||||
#? int()
|
#? int()
|
||||||
b[8-7]
|
b[8-7]
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# Slices
|
||||||
|
# -----------------
|
||||||
#? list()
|
#? list()
|
||||||
b[8:]
|
b[8:]
|
||||||
|
|
||||||
@@ -37,6 +40,14 @@ b[8:]
|
|||||||
b[int():]
|
b[int():]
|
||||||
|
|
||||||
|
|
||||||
|
class _StrangeSlice():
|
||||||
|
def __getitem__(self, slice):
|
||||||
|
return slice
|
||||||
|
|
||||||
|
#? []
|
||||||
|
_StrangeSlice()[1:2]
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# iterable multiplication
|
# iterable multiplication
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user