forked from VimPlug/jedi
Fix all remaining issues from the compiled refactoring except static analysis.
This commit is contained in:
@@ -200,18 +200,31 @@ class CompiledObject(Base):
|
||||
pass # self.obj maynot have an __iter__ method.
|
||||
return result
|
||||
|
||||
@property
|
||||
def py__getitem__(self):
|
||||
if not hasattr(self.obj, '__getitem__'):
|
||||
raise AttributeError('No __getitem__ on %s' % self.obj)
|
||||
|
||||
def actual(index):
|
||||
if type(self.obj) not in (str, list, tuple, unicode, bytes, bytearray, dict):
|
||||
# Get rid of side effects, we won't call custom `__getitem__`s.
|
||||
return set()
|
||||
|
||||
return set([create(self._evaluator, self.obj[index])])
|
||||
return actual
|
||||
|
||||
@property
|
||||
def py__iter__(self):
|
||||
if not hasattr(self.obj, '__iter__'):
|
||||
raise AttributeError('No __iter__ on %s' % self.obj)
|
||||
|
||||
def actual(evaluator):
|
||||
def actual():
|
||||
if type(self.obj) not in (str, list, tuple, unicode, bytes, bytearray, dict):
|
||||
# Get rid of side effects, we won't call custom `__getitem__`s.
|
||||
return
|
||||
|
||||
for part in self.obj:
|
||||
yield set([create(evaluator, part)])
|
||||
yield set([create(self._evaluator, part)])
|
||||
return actual
|
||||
|
||||
@property
|
||||
@@ -505,10 +518,7 @@ def get_special_object(evaluator, identifier):
|
||||
def compiled_objects_cache(func):
|
||||
def wrapper(evaluator, obj, parent=None, module=None):
|
||||
# Do a very cheap form of caching here.
|
||||
if parent is None and not inspect.ismodule(obj):
|
||||
parent = create(evaluator, _builtins)
|
||||
|
||||
key = id(obj), id(parent), id(module)
|
||||
key = id(obj)
|
||||
try:
|
||||
return evaluator.compiled_cache[key][0]
|
||||
except KeyError:
|
||||
@@ -525,6 +535,9 @@ def create(evaluator, obj, parent=None, module=None):
|
||||
A very weird interface class to this module. The more options provided the
|
||||
more acurate loading compiled objects is.
|
||||
"""
|
||||
if parent is None and not inspect.ismodule(obj):
|
||||
parent = create(evaluator, _builtins)
|
||||
|
||||
if not inspect.ismodule(obj):
|
||||
faked = fake.get_faked(module and module.obj, obj)
|
||||
if faked is not None:
|
||||
|
||||
@@ -404,7 +404,7 @@ class FakeSequence(_FakeArray):
|
||||
|
||||
class AlreadyEvaluated(frozenset):
|
||||
"""A simple container to add already evaluated objects to an array."""
|
||||
def get_code(self):
|
||||
def get_code(self, normalized=False):
|
||||
# For debugging purposes.
|
||||
return str(self)
|
||||
|
||||
@@ -523,6 +523,7 @@ def py__getitem__(evaluator, types, index, node):
|
||||
if isinstance(typ, Array) and typ.type == 'dict':
|
||||
types.remove(typ)
|
||||
result |= typ.dict_values()
|
||||
print('ITER', types, py__iter__types(evaluator, types))
|
||||
return result | py__iter__types(evaluator, types)
|
||||
|
||||
for typ in types:
|
||||
|
||||
Reference in New Issue
Block a user