summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Balparda <balparda@google.com>2013-12-04 16:14:16 -0800
committerDaniel Balparda <balparda@google.com>2013-12-04 16:14:16 -0800
commited7febe8b926ca91063992936f82ff4df22a2ea5 (patch)
tree38f712e81b96c2214b1b288ebda201634c554301
parentc3a874766f86e7ded87a2e386be3b0f3ab8dc638 (diff)
downloadpylint-ed7febe8b926ca91063992936f82ff4df22a2ea5.tar.gz
Adding a new message for pylint (I0022, deprecated-pragma) that warns on the deprecated pragma disable-msg and enable-msg suppressions.
-rw-r--r--ChangeLog9
-rw-r--r--lint.py11
-rw-r--r--test/input/func_i0022.py22
-rw-r--r--test/messages/func_i0022.txt13
4 files changed, 49 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c389a3..fbba321 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,8 +2,13 @@ ChangeLog for Pylint
====================
--
+
+ * Add new check for use of deprecated pragma directives "pylint:disable-msg"
+ or "pylint:enable-msg" (I0022, deprecated-pragma) which was previously
+ emmited as a regular warn()
+
* Avoid false used-before-assignment for except handler defined
- identifier used on the same line (#111)
+ identifier used on the same line (#111)
* Add 'bad-context-manager' error, checking that '__exit__'
special method accepts the right number of arguments.
@@ -16,7 +21,7 @@ ChangeLog for Pylint
have basic input validation (bitbucket #53 and #54), patches provided by
felipeochoa and Brian Lane
- * Added a new warning, 'non-iterator-returned', for non-iterators
+ * Added a new warning, 'non-iterator-returned', for non-iterators
returned by '__iter__'
* Add new warning for unpacking non-sequences in assignments
diff --git a/lint.py b/lint.py
index 30f83de..823e94b 100644
--- a/lint.py
+++ b/lint.py
@@ -134,7 +134,11 @@ MSGS = {
'useless-suppression',
'Reported when a message is explicitly disabled for a line or '
'a block of code, but never triggered.'),
-
+ 'I0022': ('Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"',
+ 'deprecated-pragma',
+ 'You should preferably use "pylint:disable" or "pylint:enable" '
+ 'instead of the deprecated suppression pragma style '
+ '"pylint:disable-msg" or "pylint:enable-msg"'),
'E0001': ('%s',
'syntax-error',
@@ -470,9 +474,8 @@ This is used by the global evaluation report (RP0004).'}),
meth = self._options_methods[opt]
except KeyError:
meth = self._bw_options_methods[opt]
- warn('%s is deprecated, replace it with %s (%s, line %s)' % (
- opt, opt.split('-')[0], self.current_file, line),
- DeprecationWarning)
+ # found a "(dis|en)able-msg" pragma deprecated suppresssion
+ self.add_message('deprecated-pragma', line=start[0])
for msgid in splitstrip(value):
try:
if (opt, msgid) == ('disable', 'all'):
diff --git a/test/input/func_i0022.py b/test/input/func_i0022.py
new file mode 100644
index 0000000..f5b308f
--- /dev/null
+++ b/test/input/func_i0022.py
@@ -0,0 +1,22 @@
+"""Deprecated suppression style."""
+
+__revision__ = None
+
+a = 1 # pylint: disable=invalid-name
+b = 1 # pylint: disable-msg=invalid-name
+
+# pylint: disable=invalid-name
+c = 1
+# pylint: enable=invalid-name
+
+# pylint: disable-msg=invalid-name
+d = 1
+# pylint: enable-msg=invalid-name
+
+# pylint: disable-msg=C0103
+e = 1
+# pylint: enable-msg=C0103
+
+# pylint: disable=C0103
+f = 1
+# pylint: enable=C0103
diff --git a/test/messages/func_i0022.txt b/test/messages/func_i0022.txt
new file mode 100644
index 0000000..477335c
--- /dev/null
+++ b/test/messages/func_i0022.txt
@@ -0,0 +1,13 @@
+I: 5: Locally disabling C0103
+I: 5: Suppressed 'invalid-name' (from line 5)
+I: 6: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 6: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 6: Suppressed 'invalid-name' (from line 6)
+I: 9: Suppressed 'invalid-name' (from line 8)
+I: 12: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 13: Suppressed 'invalid-name' (from line 12)
+I: 14: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 16: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 17: Suppressed 'invalid-name' (from line 16)
+I: 18: Deprecated pragma "pylint:disable-msg" or "pylint:enable-msg"
+I: 21: Suppressed 'invalid-name' (from line 20)