From d4c467eaa089112c06d7ddf944ea0c4446476e20 Mon Sep 17 00:00:00 2001 From: James Morgensen Date: Thu, 30 Apr 2015 22:33:18 -0700 Subject: Fix issue #223 (ignored_modules should apply to import errors too). The fix will ignore import errors caused by attempting to import any name which is or is a subpackage of a module listed in ignored_modules. --- pylint/checkers/imports.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index b195297..eb93b4f 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -29,7 +29,7 @@ from astroid import are_exclusive from astroid.modutils import get_module_part, is_standard_module from pylint.interfaces import IAstroidChecker -from pylint.utils import EmptyReport +from pylint.utils import EmptyReport, get_global_option from pylint.checkers import BaseChecker from pylint.checkers.utils import check_messages, is_import_error @@ -291,7 +291,10 @@ given file (report RP0402 must not be disabled)'} args = '%r (%s)' % (modname, ex) else: args = repr(modname) - if not _except_import_error(importnode.parent): + ignored_modules = get_global_option(self, 'ignored-modules', default=[]) + while modname and modname not in ignored_modules: + modname = modname.rpartition('.')[0] + if not modname and not _except_import_error(importnode.parent): self.add_message("import-error", args=args, node=importnode) def _check_relative_import(self, modnode, importnode, importedmodnode, -- cgit v1.2.1