More issues from the list of types to set of types conversion.

This commit is contained in:
Dave Halter
2015-10-30 10:32:17 +01:00
parent 05798734bf
commit ee51b0a62f
3 changed files with 5 additions and 5 deletions

View File

@@ -322,7 +322,7 @@ class BaseDefinition(object):
elif self._definition.isinstance(tree.Import): elif self._definition.isinstance(tree.Import):
return imports.ImportWrapper(self._evaluator, self._name).follow() return imports.ImportWrapper(self._evaluator, self._name).follow()
else: else:
return [self._definition] return set([self._definition])
@property @property
@memoize_default() @memoize_default()
@@ -331,7 +331,7 @@ class BaseDefinition(object):
Raises an ``AttributeError``if the definition is not callable. Raises an ``AttributeError``if the definition is not callable.
Otherwise returns a list of `Definition` that represents the params. Otherwise returns a list of `Definition` that represents the params.
""" """
followed = self._follow_statements_imports() followed = list(self._follow_statements_imports())
if not followed or not hasattr(followed[0], 'py__call__'): if not followed or not hasattr(followed[0], 'py__call__'):
raise AttributeError() raise AttributeError()
followed = followed[0] # only check the first one. followed = followed[0] # only check the first one.
@@ -449,7 +449,7 @@ class Completion(BaseDefinition):
followed = self._follow_statements_imports() followed = self._follow_statements_imports()
if followed: if followed:
# TODO: Use all of the followed objects as input to Documentation. # TODO: Use all of the followed objects as input to Documentation.
definition = followed[0] definition = list(followed)[0]
if raw: if raw:
return _Help(definition).raw() return _Help(definition).raw()

View File

@@ -194,7 +194,7 @@ class CompiledObject(Base):
if not result: if not result:
try: try:
for obj in self.obj: for obj in self.obj:
result.append(CompiledObject(obj)) result.add(CompiledObject(obj))
except TypeError: except TypeError:
pass # self.obj maynot have an __iter__ method. pass # self.obj maynot have an __iter__ method.
return result return result

View File

@@ -12,7 +12,7 @@ def test_simple():
obj = compiled.CompiledObject('_str_', bltn) obj = compiled.CompiledObject('_str_', bltn)
upper = e.find_types(obj, 'upper') upper = e.find_types(obj, 'upper')
assert len(upper) == 1 assert len(upper) == 1
objs = list(e.execute(upper[0])) objs = list(e.execute(list(upper)[0]))
assert len(objs) == 1 assert len(objs) == 1
assert isinstance(objs[0], representation.Instance) assert isinstance(objs[0], representation.Instance)