diff options
author | Cezar <celnazli@bitdefender.com> | 2015-09-19 14:23:33 +0300 |
---|---|---|
committer | Cezar <celnazli@bitdefender.com> | 2015-09-19 14:23:33 +0300 |
commit | db13406de00af99a299aaf728f103f82947ace20 (patch) | |
tree | 460b377d2d7e35758aa9f6fb4cd21e645c10a01d | |
parent | 9cca374b0bb83426f85768b5545c84ae8b57ddb3 (diff) | |
download | pylint-db13406de00af99a299aaf728f103f82947ace20.tar.gz |
Raise 'reimported' on duplice import on single line
-rw-r--r-- | pylint/checkers/imports.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 2992991..b66f6aa 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -287,6 +287,12 @@ given file (report RP0402 must not be disabled)'} return self._check_relative_import(modnode, node, importedmodnode, basename) self._check_deprecated_module(node, basename) + + for i in range(len(node.names)): + if node.names[i] in node.names[i + 1:]: + self.add_message('reimported', node=node, + args=(node.names[i][0], node.fromlineno)) + for name, _ in node.names: if name != '*': self._add_imported_module(node, '%s.%s' % (importedmodnode.name, name)) @@ -372,6 +378,7 @@ given file (report RP0402 must not be disabled)'} """check if the import is necessary (i.e. not already done)""" if not self.linter.is_message_enabled('reimported'): return + frame = node.frame() root = node.root() contexts = [(frame, level)] |