summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura M?dioni <laura.medioni@logilab.fr>2015-11-10 13:36:56 +0100
committerLaura M?dioni <laura.medioni@logilab.fr>2015-11-10 13:36:56 +0100
commit38fd37a36933409625f422cbd7b91740540e3172 (patch)
treefe0d1b372cb7098ceb91ab8725123661ffb77046
parent722446bab92ad13489d73119d534c9a7cf8f8b2c (diff)
downloadpylint-38fd37a36933409625f422cbd7b91740540e3172.tar.gz
Check imports are located at the top of the module (right after docstring and comments)
related to issue #692
-rw-r--r--CONTRIBUTORS.txt3
-rw-r--r--pylint/__pkginfo__.py2
-rw-r--r--pylint/checkers/imports.py36
-rw-r--r--pylint/test/functional/arguments.py2
-rw-r--r--pylint/test/functional/class_members_py27.py2
-rw-r--r--pylint/test/functional/defined_and_used_on_same_line.py2
-rw-r--r--pylint/test/functional/indexing_exception.py2
-rw-r--r--pylint/test/functional/init_not_called.py2
-rw-r--r--pylint/test/functional/invalid_exceptions_caught.py2
-rw-r--r--pylint/test/functional/invalid_name.py2
-rw-r--r--pylint/test/functional/iterable_context.py2
-rw-r--r--pylint/test/functional/mapping_context.py2
-rw-r--r--pylint/test/functional/membership_protocol.py2
-rw-r--r--pylint/test/functional/namedtuple_member_inference.py2
-rw-r--r--pylint/test/functional/not_context_manager.py2
-rw-r--r--pylint/test/functional/socketerror_import.py2
-rw-r--r--pylint/test/functional/unsubscriptable_value.py2
-rw-r--r--pylint/test/functional/unused_import.py2
-rw-r--r--pylint/test/input/func_3k_removed_stuff_py_30.py2
-rw-r--r--pylint/test/input/func_bad_assigment_to_exception_var.py2
-rw-r--r--pylint/test/input/func_bug113231.py4
-rw-r--r--pylint/test/input/func_dotted_ancestor.py4
-rw-r--r--pylint/test/input/func_e12xx.py3
-rw-r--r--pylint/test/input/func_logging_not_lazy_with_logger.py3
-rw-r--r--pylint/test/input/func_noerror_builtin_module_test.py4
-rw-r--r--pylint/test/input/func_w0233.py4
-rw-r--r--pylint/test/input/func_w0401_package/all_the_things.py2
-rw-r--r--pylint/test/input/func_w0401_package/thing2.py2
-rw-r--r--pylint/test/input/func_w0404.py2
-rw-r--r--pylint/test/input/func_w0405.py6
-rw-r--r--pylint/test/input/func_w0406.py3
-rw-r--r--pylint/test/input/func_w0623_py_30.py4
-rw-r--r--pylint/test/messages/func_3k_removed_stuff_py_30.txt6
-rw-r--r--pylint/test/messages/func_e12xx.txt10
-rw-r--r--pylint/test/messages/func_logging_not_lazy_with_logger.txt6
-rw-r--r--pylint/test/messages/func_w0233.txt6
-rw-r--r--pylint/test/messages/func_w0404.txt10
-rw-r--r--pylint/test/messages/func_w0405.txt4
-rw-r--r--pylint/test/messages/func_w0406.txt2
-rw-r--r--pylint/test/regrtest_data/import_package_subpackage_module.py2
-rw-r--r--pylint/test/regrtest_data/package/__init__.py3
-rw-r--r--pylint/test/regrtest_data/precedence_test.py2
42 files changed, 104 insertions, 63 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 276a63d..d912d37 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -75,4 +75,5 @@ Order doesn't matter (not that much, at least ;)
* Laura Medioni (Logilab, on behalf of the CNES): misplaced-comparison-constant,
no-classmethod-decorator, no-staticmethod-decorator, too-many-nested-blocks,
- too-many-boolean-expressions, unneeded-not, wrong-import-order, ungrouped-imports \ No newline at end of file
+ too-many-boolean-expressions, unneeded-not, wrong-import-order, ungrouped-imports,
+ wrong-import-position \ No newline at end of file
diff --git a/pylint/__pkginfo__.py b/pylint/__pkginfo__.py
index edac893..2bb45bd 100644
--- a/pylint/__pkginfo__.py
+++ b/pylint/__pkginfo__.py
@@ -18,6 +18,7 @@
from __future__ import absolute_import
import sys
+from os.path import join
modname = distname = 'pylint'
@@ -72,7 +73,6 @@ long_desc = """\
Pylint is shipped with "pylint-gui", "pyreverse" (UML diagram generator)
and "symilar" (an independent similarities checker)."""
-from os.path import join
scripts = [join('bin', filename)
for filename in ('pylint', 'pylint-gui', "symilar", "epylint",
"pyreverse")]
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py
index fc854ab..480adde 100644
--- a/pylint/checkers/imports.py
+++ b/pylint/checkers/imports.py
@@ -187,6 +187,10 @@ MSGS = {
'C0412': ('Imports from package %s are not grouped',
'ungrouped-imports',
'Used when imports are not grouped by packages'),
+ 'C0413': ('Wrong import position: %s should be placed at the top of the '
+ 'module',
+ 'wrong-import-position',
+ 'Used when code and imports are mixed'),
}
class ImportsChecker(BaseChecker):
@@ -243,6 +247,7 @@ given file (report RP0402 must not be disabled)'}
self.stats = None
self.import_graph = None
self._imports_stack = []
+ self._first_non_import_node = None
self.__int_dep_info = self.__ext_dep_info = None
self.reports = (('RP0401', 'External dependencies',
self.report_external_dependencies),
@@ -267,6 +272,7 @@ given file (report RP0402 must not be disabled)'}
for cycle in get_cycles(self.import_graph, vertices=vertices):
self.add_message('cyclic-import', args=' -> '.join(cycle))
+ @check_messages('wrong-import-position')
def visit_import(self, node):
"""triggered when an import statement is seen"""
modnode = node.root()
@@ -280,6 +286,7 @@ given file (report RP0402 must not be disabled)'}
importedname = importedmodnode.name if importedmodnode else None
if not importedname:
importedname = node.names[0][0].split('.')[0]
+ self._check_position(node)
self._imports_stack.append((node, importedname))
if importedmodnode is None:
continue
@@ -313,6 +320,7 @@ given file (report RP0402 must not be disabled)'}
if not importedname:
importedname = node.names[0][0].split('.')[0]
self._imports_stack.append((node, importedname))
+ self._check_position(node)
if importedmodnode is None:
return
self._check_relative_import(modnode, node, importedmodnode, basename)
@@ -348,6 +356,34 @@ given file (report RP0402 must not be disabled)'}
break
packages.append(imp[1])
self._imports_stack = []
+ self._first_non_import_node = None
+
+ def visit_if(self, node):
+ # if the node does not contain an import instruction, and if it is the
+ # first node of the module different from an import instruction, keep a
+ # track of it
+ if self._first_non_import_node:
+ return
+ for _ in node.nodes_of_class(astroid.Import):
+ return
+ for _ in node.nodes_of_class(astroid.ImportFrom):
+ return
+ if isinstance(node.parent, astroid.Module):
+ self._first_non_import_node = node
+
+ visit_tryfinally = visit_tryexcept = visit_assign = visit_ifexp = visit_comprehension = visit_if
+
+ def visit_functiondef(self, node):
+ if not self._first_non_import_node:
+ self._first_non_import_node = node
+
+ visit_classdef = visit_for = visit_while = visit_functiondef
+
+ def _check_position(self, node):
+ """Sends a message if import `node` comes after another piece of code"""
+ if self._first_non_import_node:
+ self.add_message('wrong-import-position', node=node,
+ args='"%s"' % node.as_string())
def _check_imports_order(self, node):
"""Checks imports of module `node` are grouped by category
diff --git a/pylint/test/functional/arguments.py b/pylint/test/functional/arguments.py
index 8ae008d..f994665 100644
--- a/pylint/test/functional/arguments.py
+++ b/pylint/test/functional/arguments.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods, no-absolute-import,missing-docstring,import-error
+# pylint: disable=too-few-public-methods, no-absolute-import,missing-docstring,import-error,wrong-import-position
"""Test function argument checker"""
def decorator(fun):
diff --git a/pylint/test/functional/class_members_py27.py b/pylint/test/functional/class_members_py27.py
index 97f2962..40e78cd 100644
--- a/pylint/test/functional/class_members_py27.py
+++ b/pylint/test/functional/class_members_py27.py
@@ -1,5 +1,5 @@
""" Various tests for class members access. """
-# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment,import-error,no-init,missing-docstring, wrong-import-order
+# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment,import-error,no-init,missing-docstring, wrong-import-order,wrong-import-position
from missing import Missing
class MyClass(object):
"""class docstring"""
diff --git a/pylint/test/functional/defined_and_used_on_same_line.py b/pylint/test/functional/defined_and_used_on_same_line.py
index 1d6bc99..a61bcd7 100644
--- a/pylint/test/functional/defined_and_used_on_same_line.py
+++ b/pylint/test/functional/defined_and_used_on_same_line.py
@@ -1,5 +1,5 @@
"""Check for definitions and usage happening on the same line."""
-#pylint: disable=missing-docstring,multiple-statements,no-absolute-import,parameter-unpacking
+#pylint: disable=missing-docstring,multiple-statements,no-absolute-import,parameter-unpacking,wrong-import-position
from __future__ import print_function
print([index
for index in range(10)])
diff --git a/pylint/test/functional/indexing_exception.py b/pylint/test/functional/indexing_exception.py
index 7ea50d5..9ac1a7c 100644
--- a/pylint/test/functional/indexing_exception.py
+++ b/pylint/test/functional/indexing_exception.py
@@ -2,9 +2,9 @@
Check for indexing exceptions.
"""
# pylint: disable=import-error, no-absolute-import
-__revision__ = 0
from unknown import ExtensionException
+__revision__ = 0
class SubException(IndexError):
""" empty """
diff --git a/pylint/test/functional/init_not_called.py b/pylint/test/functional/init_not_called.py
index 43629c7..38c0f7a 100644
--- a/pylint/test/functional/init_not_called.py
+++ b/pylint/test/functional/init_not_called.py
@@ -1,4 +1,4 @@
-# pylint: disable=R0903,import-error, missing-docstring
+# pylint: disable=R0903,import-error,missing-docstring,wrong-import-position
"""test for __init__ not called
"""
from __future__ import print_function
diff --git a/pylint/test/functional/invalid_exceptions_caught.py b/pylint/test/functional/invalid_exceptions_caught.py
index 545954d..1eca134 100644
--- a/pylint/test/functional/invalid_exceptions_caught.py
+++ b/pylint/test/functional/invalid_exceptions_caught.py
@@ -1,5 +1,5 @@
"""Test for catching non-exceptions."""
-# pylint: disable=too-many-ancestors, no-absolute-import, import-error, multiple-imports
+# pylint: disable=too-many-ancestors, no-absolute-import, import-error, multiple-imports,wrong-import-position
from __future__ import print_function
import socket, binascii
diff --git a/pylint/test/functional/invalid_name.py b/pylint/test/functional/invalid_name.py
index 1b45748..b4107b3 100644
--- a/pylint/test/functional/invalid_name.py
+++ b/pylint/test/functional/invalid_name.py
@@ -1,5 +1,5 @@
""" Tests for invalid-name checker. """
-# pylint: disable=unused-import, no-absolute-import
+# pylint: disable=unused-import, no-absolute-import, wrong-import-position
AAA = 24
try:
diff --git a/pylint/test/functional/iterable_context.py b/pylint/test/functional/iterable_context.py
index fa4e617..05d8589 100644
--- a/pylint/test/functional/iterable_context.py
+++ b/pylint/test/functional/iterable_context.py
@@ -2,7 +2,7 @@
Checks that primitive values are not used in an
iterating/mapping context.
"""
-# pylint: disable=missing-docstring,invalid-name,too-few-public-methods,no-init,no-self-use,import-error,unused-argument,bad-mcs-method-argument
+# pylint: disable=missing-docstring,invalid-name,too-few-public-methods,no-init,no-self-use,import-error,unused-argument,bad-mcs-method-argument,wrong-import-position
from __future__ import print_function
# primitives
diff --git a/pylint/test/functional/mapping_context.py b/pylint/test/functional/mapping_context.py
index 72457b8..6968994 100644
--- a/pylint/test/functional/mapping_context.py
+++ b/pylint/test/functional/mapping_context.py
@@ -1,7 +1,7 @@
"""
Checks that only valid values are used in a mapping context.
"""
-# pylint: disable=missing-docstring,invalid-name,too-few-public-methods,no-self-use,import-error
+# pylint: disable=missing-docstring,invalid-name,too-few-public-methods,no-self-use,import-error,wrong-import-position
from __future__ import print_function
diff --git a/pylint/test/functional/membership_protocol.py b/pylint/test/functional/membership_protocol.py
index 0fd4886..6b514d8 100644
--- a/pylint/test/functional/membership_protocol.py
+++ b/pylint/test/functional/membership_protocol.py
@@ -1,4 +1,4 @@
-# pylint: disable=missing-docstring,pointless-statement,expression-not-assigned,too-few-public-methods,import-error,no-init
+# pylint: disable=missing-docstring,pointless-statement,expression-not-assigned,too-few-public-methods,import-error,no-init,wrong-import-position
# standard types
1 in [1, 2, 3]
diff --git a/pylint/test/functional/namedtuple_member_inference.py b/pylint/test/functional/namedtuple_member_inference.py
index 5fe6b19..4488ceb 100644
--- a/pylint/test/functional/namedtuple_member_inference.py
+++ b/pylint/test/functional/namedtuple_member_inference.py
@@ -4,10 +4,10 @@ Regression test for:
https://bitbucket.org/logilab/pylint/issue/93/pylint-crashes-on-namedtuple-attribute
"""
from __future__ import absolute_import, print_function
+from collections import namedtuple
__revision__ = None
-from collections import namedtuple
Thing = namedtuple('Thing', ())
Fantastic = namedtuple('Fantastic', ['foo'])
diff --git a/pylint/test/functional/not_context_manager.py b/pylint/test/functional/not_context_manager.py
index 97f6e97..3d56b60 100644
--- a/pylint/test/functional/not_context_manager.py
+++ b/pylint/test/functional/not_context_manager.py
@@ -1,7 +1,7 @@
"""Tests that onjects used in a with statement implement context manager protocol"""
# pylint: disable=too-few-public-methods, invalid-name, import-error, missing-docstring
-# pylint: disable=no-init
+# pylint: disable=no-init,wrong-import-position
# Tests no messages for objects that implement the protocol
class Manager(object):
def __enter__(self):
diff --git a/pylint/test/functional/socketerror_import.py b/pylint/test/functional/socketerror_import.py
index 5028f02..df5de29 100644
--- a/pylint/test/functional/socketerror_import.py
+++ b/pylint/test/functional/socketerror_import.py
@@ -1,6 +1,6 @@
"""ds"""
from __future__ import absolute_import, print_function
+from socket import error
__revision__ = '$Id: socketerror_import.py,v 1.2 2005-12-28 14:58:22 syt Exp $'
-from socket import error
print(error)
diff --git a/pylint/test/functional/unsubscriptable_value.py b/pylint/test/functional/unsubscriptable_value.py
index 64cafaf..7f2ceae 100644
--- a/pylint/test/functional/unsubscriptable_value.py
+++ b/pylint/test/functional/unsubscriptable_value.py
@@ -2,7 +2,7 @@
Checks that value used in a subscript supports subscription
(i.e. defines __getitem__ method).
"""
-# pylint: disable=missing-docstring,pointless-statement,expression-not-assigned
+# pylint: disable=missing-docstring,pointless-statement,expression-not-assigned,wrong-import-position
# pylint: disable=too-few-public-methods,import-error,invalid-name,wrong-import-order
import six
diff --git a/pylint/test/functional/unused_import.py b/pylint/test/functional/unused_import.py
index bec7fe9..d1a4c6b 100644
--- a/pylint/test/functional/unused_import.py
+++ b/pylint/test/functional/unused_import.py
@@ -1,5 +1,5 @@
"""unused import"""
-# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring
+# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring,wrong-import-position
import xml.etree # [unused-import]
import xml.sax # [unused-import]
import os.path as test # [unused-import]
diff --git a/pylint/test/input/func_3k_removed_stuff_py_30.py b/pylint/test/input/func_3k_removed_stuff_py_30.py
index 3d23069..54ad935 100644
--- a/pylint/test/input/func_3k_removed_stuff_py_30.py
+++ b/pylint/test/input/func_3k_removed_stuff_py_30.py
@@ -1,9 +1,9 @@
"""test relative import"""
# pylint: disable=no-absolute-import
from __future__ import print_function
+import func_w0401
__revision__ = filter(None, map(str, (1, 2, 3)))
-import func_w0401
def function():
"""something"""
diff --git a/pylint/test/input/func_bad_assigment_to_exception_var.py b/pylint/test/input/func_bad_assigment_to_exception_var.py
index 640fcf0..93d0644 100644
--- a/pylint/test/input/func_bad_assigment_to_exception_var.py
+++ b/pylint/test/input/func_bad_assigment_to_exception_var.py
@@ -1,8 +1,8 @@
# pylint:disable=C0103, print-statement, no-absolute-import
"""ho ho ho"""
from __future__ import print_function
-__revision__ = 'toto'
import sys
+__revision__ = 'toto'
e = 1
e2 = 'yo'
diff --git a/pylint/test/input/func_bug113231.py b/pylint/test/input/func_bug113231.py
index 1697ed6..70602e2 100644
--- a/pylint/test/input/func_bug113231.py
+++ b/pylint/test/input/func_bug113231.py
@@ -4,11 +4,11 @@
"""test bugfix for #113231 in logging checker
"""
from __future__ import absolute_import
-__revision__ = ''
-
# Muck up the names in an effort to confuse...
import logging as renamed_logging
+__revision__ = ''
+
class Logger(object):
"""Fake logger"""
pass
diff --git a/pylint/test/input/func_dotted_ancestor.py b/pylint/test/input/func_dotted_ancestor.py
index 0603524..ff32858 100644
--- a/pylint/test/input/func_dotted_ancestor.py
+++ b/pylint/test/input/func_dotted_ancestor.py
@@ -1,10 +1,10 @@
"""bla"""
# pylint: disable=no-absolute-import
-__revision__ = 'yo'
-
from input import func_w0233
+__revision__ = 'yo'
+
class Aaaa(func_w0233.AAAA):
"""test dotted name in ancestors"""
def __init__(self):
diff --git a/pylint/test/input/func_e12xx.py b/pylint/test/input/func_e12xx.py
index 67475d1..74984d9 100644
--- a/pylint/test/input/func_e12xx.py
+++ b/pylint/test/input/func_e12xx.py
@@ -2,9 +2,10 @@
"""Test checking of log format strings
"""
+import logging
+
__revision__ = ''
-import logging
def pprint():
"""Test string format in logging statements.
diff --git a/pylint/test/input/func_logging_not_lazy_with_logger.py b/pylint/test/input/func_logging_not_lazy_with_logger.py
index afbe285..973a5c7 100644
--- a/pylint/test/input/func_logging_not_lazy_with_logger.py
+++ b/pylint/test/input/func_logging_not_lazy_with_logger.py
@@ -1,9 +1,8 @@
"""Logging warnings using a logger class."""
from __future__ import absolute_import
-__revision__ = ''
-
import logging
+__revision__ = ''
LOG = logging.getLogger("domain")
LOG.debug("%s" % "junk")
diff --git a/pylint/test/input/func_noerror_builtin_module_test.py b/pylint/test/input/func_noerror_builtin_module_test.py
index f73694a..9b1e7ce 100644
--- a/pylint/test/input/func_noerror_builtin_module_test.py
+++ b/pylint/test/input/func_noerror_builtin_module_test.py
@@ -1,8 +1,10 @@
"""test import from a builtin module"""
+
from __future__ import absolute_import
+from math import log10
+
__revision__ = None
-from math import log10
def log10_2():
"""bla bla bla"""
diff --git a/pylint/test/input/func_w0233.py b/pylint/test/input/func_w0233.py
index 6427232..f373d4f 100644
--- a/pylint/test/input/func_w0233.py
+++ b/pylint/test/input/func_w0233.py
@@ -2,6 +2,8 @@
"""test for call to __init__ from a non ancestor class
"""
from __future__ import print_function
+from . import func_w0233
+import nonexistant
__revision__ = '$Id: func_w0233.py,v 1.2 2004-09-29 08:35:13 syt Exp $'
class AAAA(object):
@@ -17,8 +19,6 @@ class BBBBMixin(object):
def __init__(self):
print('init', self)
-import nonexistant
-from . import func_w0233
class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB, nonexistant.AClass):
"""mix different things, some inferable some not"""
def __init__(self):
diff --git a/pylint/test/input/func_w0401_package/all_the_things.py b/pylint/test/input/func_w0401_package/all_the_things.py
index 67a627e..b8bd47b 100644
--- a/pylint/test/input/func_w0401_package/all_the_things.py
+++ b/pylint/test/input/func_w0401_package/all_the_things.py
@@ -1,9 +1,9 @@
"""All the things!"""
# pylint: disable=no-absolute-import
-__revision__ = None
from .thing1 import THING1
from .thing2 import THING2
from .thing2 import THING1_PLUS_THING2
+__revision__ = None
_ = (THING1, THING2, THING1_PLUS_THING2)
del _
diff --git a/pylint/test/input/func_w0401_package/thing2.py b/pylint/test/input/func_w0401_package/thing2.py
index 987965e..66d3316 100644
--- a/pylint/test/input/func_w0401_package/thing2.py
+++ b/pylint/test/input/func_w0401_package/thing2.py
@@ -1,7 +1,7 @@
"""The second thing."""
# pylint: disable=no-absolute-import
-__revision__ = None
from .all_the_things import THING1
+__revision__ = None
THING2 = "I am thing2"
THING1_PLUS_THING2 = "%s, plus %s" % (THING1, THING2)
diff --git a/pylint/test/input/func_w0404.py b/pylint/test/input/func_w0404.py
index b9169d7..5111c60 100644
--- a/pylint/test/input/func_w0404.py
+++ b/pylint/test/input/func_w0404.py
@@ -1,6 +1,5 @@
"""Unittests for W0404 (reimport)"""
from __future__ import absolute_import, print_function
-__revision__ = 0
import sys
@@ -11,6 +10,7 @@ from email import encoders
import email.encoders
import sys #pylint: disable=ungrouped-imports
+__revision__ = 0
def no_reimport():
"""docstring"""
diff --git a/pylint/test/input/func_w0405.py b/pylint/test/input/func_w0405.py
index 3f6efc7..50a069d 100644
--- a/pylint/test/input/func_w0405.py
+++ b/pylint/test/input/func_w0405.py
@@ -1,14 +1,14 @@
"""check reimport
"""
from __future__ import absolute_import, print_function
-__revision__ = 0
-# pylint: disable=using-constant-test,ungrouped-imports
+
+# pylint: disable=using-constant-test,ungrouped-imports,wrong-import-position
import os
from os.path import join, exists
-
import os
import re as _re
+__revision__ = 0
_re.match('yo', '.*')
if __revision__:
diff --git a/pylint/test/input/func_w0406.py b/pylint/test/input/func_w0406.py
index d45a6b5..ceb12b5 100644
--- a/pylint/test/input/func_w0406.py
+++ b/pylint/test/input/func_w0406.py
@@ -1,9 +1,10 @@
"""test module importing itself"""
# pylint: disable=no-absolute-import,using-constant-test
from __future__ import print_function
+from . import func_w0406
+
__revision__ = 0
-from . import func_w0406
if __revision__:
print(func_w0406)
diff --git a/pylint/test/input/func_w0623_py_30.py b/pylint/test/input/func_w0623_py_30.py
index 14c22a8..cc8d36c 100644
--- a/pylint/test/input/func_w0623_py_30.py
+++ b/pylint/test/input/func_w0623_py_30.py
@@ -1,9 +1,9 @@
"""Test for W0623, overwriting names in exception handlers."""
# pylint: disable=broad-except,bare-except,print-statement,no-absolute-import,duplicate-except
-__revision__ = ''
-
import exceptions
+__revision__ = ''
+
class MyError(Exception):
"""Special exception class."""
pass
diff --git a/pylint/test/messages/func_3k_removed_stuff_py_30.txt b/pylint/test/messages/func_3k_removed_stuff_py_30.txt
index a185672..8e3b203 100644
--- a/pylint/test/messages/func_3k_removed_stuff_py_30.txt
+++ b/pylint/test/messages/func_3k_removed_stuff_py_30.txt
@@ -1,4 +1,4 @@
E: 12:function: Instance of 'unicode' has no 'looower' member
-W: 4: Used builtin function 'filter'. Using a list comprehension can be clearer.
-W: 4: Used builtin function 'map'. Using a list comprehension can be clearer.
-W: 6: Relative import 'func_w0401', should be 'input.func_w0401'
+W: 4: Relative import 'func_w0401', should be 'input.func_w0401'
+W: 5: Used builtin function 'filter'. Using a list comprehension can be clearer.
+W: 5: Used builtin function 'map'. Using a list comprehension can be clearer.
diff --git a/pylint/test/messages/func_e12xx.txt b/pylint/test/messages/func_e12xx.txt
index d0a8b9c..92640d2 100644
--- a/pylint/test/messages/func_e12xx.txt
+++ b/pylint/test/messages/func_e12xx.txt
@@ -1,6 +1,6 @@
-E: 13:pprint: Too many arguments for logging format string
E: 14:pprint: Too many arguments for logging format string
-E: 15:pprint: Logging format string ends in middle of conversion specifier
-E: 16:pprint: Not enough arguments for logging format string
-E: 17:pprint: Unsupported logging format character 'y' (0x79) at index 3
-E: 18:pprint: Too many arguments for logging format string
+E: 15:pprint: Too many arguments for logging format string
+E: 16:pprint: Logging format string ends in middle of conversion specifier
+E: 17:pprint: Not enough arguments for logging format string
+E: 18:pprint: Unsupported logging format character 'y' (0x79) at index 3
+E: 19:pprint: Too many arguments for logging format string
diff --git a/pylint/test/messages/func_logging_not_lazy_with_logger.txt b/pylint/test/messages/func_logging_not_lazy_with_logger.txt
index 8b483a7..04823cf 100644
--- a/pylint/test/messages/func_logging_not_lazy_with_logger.txt
+++ b/pylint/test/messages/func_logging_not_lazy_with_logger.txt
@@ -1,4 +1,4 @@
+W: 8: Specify string format arguments as logging function parameters
W: 9: Specify string format arguments as logging function parameters
-W: 10: Specify string format arguments as logging function parameters
-W: 12: Specify string format arguments as logging function parameters
-W: 14: Specify string format arguments as logging function parameters
+W: 11: Specify string format arguments as logging function parameters
+W: 13: Specify string format arguments as logging function parameters
diff --git a/pylint/test/messages/func_w0233.txt b/pylint/test/messages/func_w0233.txt
index d36408b..7c7780e 100644
--- a/pylint/test/messages/func_w0233.txt
+++ b/pylint/test/messages/func_w0233.txt
@@ -1,6 +1,6 @@
-E: 20: Unable to import 'nonexistant'
+E: 6: Unable to import 'nonexistant'
E: 22:CCC: Module 'input.func_w0233' has no 'BBBB' member
E: 27:CCC.__init__: Module 'input.func_w0233' has no 'BBBB' member
E: 50:Super2.__init__: Super of 'Super2' has no '__woohoo__' member
-W: 12:AAAA.__init__: __init__ method from a non direct base class 'BBBBMixin' is called
-W: 48:Super2.__init__: __init__ method from base class 'dict' is not called \ No newline at end of file
+W: 14:AAAA.__init__: __init__ method from a non direct base class 'BBBBMixin' is called
+W: 48:Super2.__init__: __init__ method from base class 'dict' is not called
diff --git a/pylint/test/messages/func_w0404.txt b/pylint/test/messages/func_w0404.txt
index cd7f3e2..2cfc137 100644
--- a/pylint/test/messages/func_w0404.txt
+++ b/pylint/test/messages/func_w0404.txt
@@ -1,5 +1,5 @@
-W: 8: Reimport 'ElementTree' (imported line 7)
-W: 11: Reimport 'email.encoders' (imported line 10)
-W: 13: Reimport 'sys' (imported line 5)
-W: 23:reimport: Redefining name 'sys' from outer scope (line 5)
-W: 23:reimport: Reimport 'sys' (imported line 5)
+W: 7: Reimport 'ElementTree' (imported line 6)
+W: 10: Reimport 'email.encoders' (imported line 9)
+W: 12: Reimport 'sys' (imported line 4)
+W: 23:reimport: Redefining name 'sys' from outer scope (line 4)
+W: 23:reimport: Reimport 'sys' (imported line 4)
diff --git a/pylint/test/messages/func_w0405.txt b/pylint/test/messages/func_w0405.txt
index 9555dfd..072b155 100644
--- a/pylint/test/messages/func_w0405.txt
+++ b/pylint/test/messages/func_w0405.txt
@@ -1,4 +1,4 @@
-W: 9: Reimport 'os' (imported line 6)
+W: 8: Reimport 'os' (imported line 6)
W: 16: Reimport 'exists' (imported line 7)
W: 21:func: Reimport 'os' (imported line 6)
-W: 23:func: Reimport 're' (imported line 10)
+W: 23:func: Reimport 're' (imported line 9)
diff --git a/pylint/test/messages/func_w0406.txt b/pylint/test/messages/func_w0406.txt
index 8779d98..f6bc14d 100644
--- a/pylint/test/messages/func_w0406.txt
+++ b/pylint/test/messages/func_w0406.txt
@@ -1 +1 @@
-W: 6: Module import itself
+W: 4: Module import itself
diff --git a/pylint/test/regrtest_data/import_package_subpackage_module.py b/pylint/test/regrtest_data/import_package_subpackage_module.py
index 937c8c3..2864e3c 100644
--- a/pylint/test/regrtest_data/import_package_subpackage_module.py
+++ b/pylint/test/regrtest_data/import_package_subpackage_module.py
@@ -45,5 +45,5 @@ import subpackage
(3) run pylint with a script importing package.subpackage.module.
"""
-__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 16:08:54 syt Exp $'
import package.subpackage.module
+__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 16:08:54 syt Exp $'
diff --git a/pylint/test/regrtest_data/package/__init__.py b/pylint/test/regrtest_data/package/__init__.py
index 34550e9..d94c9fc 100644
--- a/pylint/test/regrtest_data/package/__init__.py
+++ b/pylint/test/regrtest_data/package/__init__.py
@@ -1,6 +1,8 @@
# pylint: disable=R0903,W0403
"""package's __init__ file"""
+from . import subpackage
+
__revision__ = 0
# E0602 - Undefined variable '__path__'
@@ -11,4 +13,3 @@ class AudioTime(object):
DECIMAL = 3
-from . import subpackage
diff --git a/pylint/test/regrtest_data/precedence_test.py b/pylint/test/regrtest_data/precedence_test.py
index 260eeb3..ff5871d 100644
--- a/pylint/test/regrtest_data/precedence_test.py
+++ b/pylint/test/regrtest_data/precedence_test.py
@@ -14,8 +14,8 @@
"""
from __future__ import print_function
+from package import AudioTime
__revision__ = 0
-from package import AudioTime
print(AudioTime.DECIMAL)