mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-22 05:11:25 +08:00
Rename explicit_absolute_import to has_explicit_absolute_import
This commit is contained in:
@@ -255,7 +255,7 @@ class ImportPath(pr.Base):
|
|||||||
if self.file_path:
|
if self.file_path:
|
||||||
sys_path_mod = list(self.sys_path_with_modifications())
|
sys_path_mod = list(self.sys_path_with_modifications())
|
||||||
module = self.import_stmt.get_parent_until()
|
module = self.import_stmt.get_parent_until()
|
||||||
if not module.explicit_absolute_import:
|
if not module.has_explicit_absolute_import:
|
||||||
# If the module explicitly asks for absolute imports,
|
# If the module explicitly asks for absolute imports,
|
||||||
# there's probably a bogus local one.
|
# there's probably a bogus local one.
|
||||||
sys_path_mod.insert(0, self.file_path)
|
sys_path_mod.insert(0, self.file_path)
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ class Scope(Simple, IsScope):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def explicit_absolute_import(self):
|
def has_explicit_absolute_import(self):
|
||||||
"""
|
"""
|
||||||
Checks if imports in this scope are explicitly absolute, i.e. there
|
Checks if imports in this scope are explicitly absolute, i.e. there
|
||||||
is a ``__future__`` import.
|
is a ``__future__`` import.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ def test_explicit_absolute_imports():
|
|||||||
Detect modules with ``from __future__ import absolute_import``.
|
Detect modules with ``from __future__ import absolute_import``.
|
||||||
"""
|
"""
|
||||||
parser = Parser("from __future__ import absolute_import", "test.py")
|
parser = Parser("from __future__ import absolute_import", "test.py")
|
||||||
assert parser.module.explicit_absolute_import
|
assert parser.module.has_explicit_absolute_import
|
||||||
|
|
||||||
|
|
||||||
def test_no_explicit_absolute_imports():
|
def test_no_explicit_absolute_imports():
|
||||||
@@ -16,7 +16,7 @@ def test_no_explicit_absolute_imports():
|
|||||||
Detect modules without ``from __future__ import absolute_import``.
|
Detect modules without ``from __future__ import absolute_import``.
|
||||||
"""
|
"""
|
||||||
parser = Parser("1", "test.py")
|
parser = Parser("1", "test.py")
|
||||||
assert not parser.module.explicit_absolute_import
|
assert not parser.module.has_explicit_absolute_import
|
||||||
|
|
||||||
|
|
||||||
def test_dont_break_imports_without_namespaces():
|
def test_dont_break_imports_without_namespaces():
|
||||||
@@ -26,7 +26,7 @@ def test_dont_break_imports_without_namespaces():
|
|||||||
"""
|
"""
|
||||||
src = "from __future__ import absolute_import\nimport xyzzy"
|
src = "from __future__ import absolute_import\nimport xyzzy"
|
||||||
parser = Parser(src, "test.py")
|
parser = Parser(src, "test.py")
|
||||||
assert parser.module.explicit_absolute_import
|
assert parser.module.has_explicit_absolute_import
|
||||||
|
|
||||||
|
|
||||||
@base.cwd_at("test/absolute_import")
|
@base.cwd_at("test/absolute_import")
|
||||||
|
|||||||
Reference in New Issue
Block a user