From 7c68ba4c451a0b762da31dc103c91f84c00b333e Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 25 Jul 2020 01:33:11 +0200 Subject: [PATCH] Remove absolute import future import checking --- parso/python/tree.py | 12 ------------ test/test_absolute_import.py | 29 ----------------------------- 2 files changed, 41 deletions(-) delete mode 100644 test/test_absolute_import.py diff --git a/parso/python/tree.py b/parso/python/tree.py index b2e6d58..850835d 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -405,18 +405,6 @@ class Module(Scope): if len(names) == 2 and names[0] == '__future__': yield names[1] - def _has_explicit_absolute_import(self): - """ - Checks if imports in this module are explicitly absolute, i.e. there - is a ``__future__`` import. - Currently not public, might be in the future. - :return bool: - """ - for name in self._iter_future_import_names(): - if name == 'absolute_import': - return True - return False - def get_used_names(self): """ Returns all the :class:`Name` leafs that exist in this module. This diff --git a/test/test_absolute_import.py b/test/test_absolute_import.py deleted file mode 100644 index c959ea5..0000000 --- a/test/test_absolute_import.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -Tests ``from __future__ import absolute_import`` (only important for -Python 2.X) -""" -from parso import parse - - -def test_explicit_absolute_imports(): - """ - Detect modules with ``from __future__ import absolute_import``. - """ - module = parse("from __future__ import absolute_import") - assert module._has_explicit_absolute_import() - - -def test_no_explicit_absolute_imports(): - """ - Detect modules without ``from __future__ import absolute_import``. - """ - assert not parse("1")._has_explicit_absolute_import() - - -def test_dont_break_imports_without_namespaces(): - """ - The code checking for ``from __future__ import absolute_import`` shouldn't - assume that all imports have non-``None`` namespaces. - """ - src = "from __future__ import absolute_import\nimport xyzzy" - assert parse(src)._has_explicit_absolute_import()