From f086f414bb421aaa384b70526cfee211ac067215 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Wed, 25 Nov 2015 19:59:38 +0200 Subject: Make some imports external instead of considering them local The assumption that a module which can't be imported is local rather than external isn't always correct, since the implementation of the astroid's import system should always find a module which is local in the current package, while it isn't necessary true that it can find always external modules, which just might be missing. --- pylint/checkers/imports.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index f1fe7c8..dea6523 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -360,7 +360,7 @@ given file (report RP0402 must not be disabled)'} return if not isinstance(node.parent, astroid.Module): return - for _ in node.nodes_of_class((astroid.Import, astroid.ImportFrom)): + if any(node.nodes_of_class((astroid.Import, astroid.ImportFrom))): return self._first_non_import_node = node @@ -419,10 +419,10 @@ given file (report RP0402 must not be disabled)'} try: filename = file_from_modpath([package]) except ImportError: - local_imports.append((node, package)) + extern_imports.append((node, package)) continue if not filename: - local_imports.append((node, package)) + extern_imports.append((node, package)) continue filename = os.path.normcase(os.path.abspath(filename)) if not any(filename.startswith(path) for path in stdlib_paths): -- cgit v1.2.1