mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Fix absolute imports.
This commit is contained in:
@@ -710,18 +710,15 @@ class SubModule(Scope, Module):
|
|||||||
Checks if imports in this module are explicitly absolute, i.e. there
|
Checks if imports in this module are explicitly absolute, i.e. there
|
||||||
is a ``__future__`` import.
|
is a ``__future__`` import.
|
||||||
"""
|
"""
|
||||||
|
# TODO this is a strange scan and not fully correct. I think Python's
|
||||||
|
# parser does it in a different way and scans for the first
|
||||||
|
# statement/import with a tokenizer (to check for syntax changes like
|
||||||
|
# the future print statement).
|
||||||
for imp in self.imports:
|
for imp in self.imports:
|
||||||
|
if isinstance(imp, ImportFrom) and imp.level == 0:
|
||||||
|
for path in imp._paths():
|
||||||
# TODO implement!
|
if [str(name) for name in path] == ['__future__', 'absolute_import']:
|
||||||
continue
|
return True
|
||||||
if not imp.from_names or not imp.namespace_names:
|
|
||||||
continue
|
|
||||||
|
|
||||||
namespace, feature = imp.from_names[0], imp.namespace_names[0]
|
|
||||||
if unicode(namespace) == "__future__" and unicode(feature) == "absolute_import":
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user