1
0
forked from VimPlug/jedi

Introduce an additional node parameter for py__iter__ which helps static analysis.

This commit is contained in:
Dave Halter
2015-12-03 11:52:54 +01:00
parent f66b8138b7
commit 8daa0b8784
6 changed files with 41 additions and 35 deletions

View File

@@ -198,16 +198,19 @@ class CompiledObject(Base):
pass # self.obj maynot have an __iter__ method.
return result
@property
def py__iter__(self):
if not hasattr(self.obj, '__iter__'):
debug.warning('Tried to call __getitem__ on non-iterable.')
return
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
raise AttributeError('No __iter__ on %s' % self.obj)
for obj in self.obj:
yield set([CompiledObject(obj)])
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 obj in self.obj:
yield set([CompiledObject(obj)])
return actual
@property
def name(self):