1
0
forked from VimPlug/jedi

test for is_nested failure

This commit is contained in:
Dave Halter
2014-05-16 13:00:13 +02:00
parent 8e27ed556e
commit 4e596060b9
4 changed files with 14 additions and 3 deletions

View File

@@ -137,5 +137,5 @@ def get_module_statements(module):
for scope in module.walk():
imports |= set(scope.imports)
stmts |= add_stmts(scope.statements)
stmts |= add_stmts(scope.returns)
stmts |= add_stmts(r for r in scope.returns if r is not None)
return stmts, imports

View File

@@ -188,7 +188,11 @@ class CompiledName(FakeName):
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
def __repr__(self):
return '<%s: (%s).%s>' % (type(self).__name__, self._obj.name, self.name)
try:
name = self._obj.name # __name__ is not defined all the time
except AttributeError:
name = None
return '<%s: (%s).%s>' % (type(self).__name__, name, self.name)
@property
@underscore_memoization

View File

@@ -795,7 +795,7 @@ class Import(Simple):
import foo.bar
"""
return not self.alias and not self.from_ns \
return not self.alias and not self.from_ns and self.namespace is not None \
and len(self.namespace.names) > 1

View File

@@ -0,0 +1,7 @@
from jedi.parser import Parser
def test_import_is_nested():
imp = Parser('import ').module.imports[0]
# should not raise an error, even if it's not a complete import
assert not imp.is_nested()