summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Morgensen <james.morgensen@gmail.com>2015-04-30 22:33:18 -0700
committerJames Morgensen <james.morgensen@gmail.com>2015-04-30 22:33:18 -0700
commitd4c467eaa089112c06d7ddf944ea0c4446476e20 (patch)
tree36cf9e5385e17fab8f5091d272f2a762807c51e2
parent5aef423bd7f371b0ba9e2fbb56aef02706581181 (diff)
downloadpylint-d4c467eaa089112c06d7ddf944ea0c4446476e20.tar.gz
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.
-rw-r--r--pylint/checkers/imports.py7
1 files 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,