diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-03 23:13:10 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-03 23:13:10 +0300 |
commit | 412e23c21d27800427f2c5a78958447e81421ac7 (patch) | |
tree | 8aa52f202d27213fcd006629d5aa78cd9a456f2a | |
parent | 10ff53c067ba2738dde7bcb39f496e7997a27e8f (diff) | |
download | pylint-412e23c21d27800427f2c5a78958447e81421ac7.tar.gz |
Enable misplaced-future for Python 3. Closes issue #580.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | pylint/checkers/imports.py | 3 | ||||
-rw-r--r-- | pylint/test/functional/misplaced_future.py | 6 | ||||
-rw-r--r-- | pylint/test/functional/misplaced_future.txt | 1 | ||||
-rw-r--r-- | pylint/test/input/func_3k_removed_stuff_py_30.py | 2 | ||||
-rw-r--r-- | pylint/test/messages/func_3k_removed_stuff_py_30.txt | 5 |
6 files changed, 13 insertions, 6 deletions
@@ -207,6 +207,8 @@ ChangeLog for Pylint pyreverse.inspector.project_from_files and pyreverse.inspector.interfaces. These were moved since they didn't belong in astroid. + + * Enable misplaced-future for Python 3. Closes issue #580. diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 7d1e713..8e91886 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -156,8 +156,7 @@ MSGS = { 'W0410': ('__future__ import is not the first non docstring statement', 'misplaced-future', 'Python 2.5 and greater require __future__ import to be the \ - first non docstring statement in the module.', - {'maxversion': (3, 0)}), + first non docstring statement in the module.'), } class ImportsChecker(BaseChecker): diff --git a/pylint/test/functional/misplaced_future.py b/pylint/test/functional/misplaced_future.py new file mode 100644 index 0000000..b4317d9 --- /dev/null +++ b/pylint/test/functional/misplaced_future.py @@ -0,0 +1,6 @@ +"""Test that __future__ is not the first statement after the docstring."""
+import collections
+from __future__ import print_function # [misplaced-future]
+from __future__ import with_statement
+
+DATA = collections
diff --git a/pylint/test/functional/misplaced_future.txt b/pylint/test/functional/misplaced_future.txt new file mode 100644 index 0000000..bc874cf --- /dev/null +++ b/pylint/test/functional/misplaced_future.txt @@ -0,0 +1 @@ +misplaced-future:3::"__future__ import is not the first non docstring statement"
\ No newline at end of file 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 75f7eb8..2633f2a 100644 --- a/pylint/test/input/func_3k_removed_stuff_py_30.py +++ b/pylint/test/input/func_3k_removed_stuff_py_30.py @@ -1,7 +1,7 @@ """test relative import""" # pylint: disable=no-absolute-import +from __future__ import print_function __revision__ = filter(None, map(str, (1, 2, 3))) -from __future__ import generators, print_function import func_w0302 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 a8e462e..a5ec95c 100644 --- a/pylint/test/messages/func_3k_removed_stuff_py_30.txt +++ b/pylint/test/messages/func_3k_removed_stuff_py_30.txt @@ -1,5 +1,4 @@ E: 12:function: Instance of 'unicode' has no 'looower' member -W: 3: Used builtin function 'filter'. Using a list comprehension can be clearer. -W: 3: Used builtin function 'map'. Using a list comprehension can be clearer. -W: 4: __future__ import is not the first non docstring statement +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_w0302', should be 'input.func_w0302' |