summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-05-07 23:30:02 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-05-07 23:30:02 +0300
commit47026a19b1d01ffbb19e6f07932f8db71a1df974 (patch)
tree36fe44e9b39a4b326cfb49fcd91b8d6bbef0fcbe
parenta0cf8df16be277b80b66d33747b342de6f82fa44 (diff)
downloadpylint-47026a19b1d01ffbb19e6f07932f8db71a1df974.tar.gz
Emit a proper deprecation warning for reporters.BaseReporter.add_message.
The alternative way is to use handle_message. add_message will be removed in Pylint 1.6.
-rw-r--r--ChangeLog5
-rw-r--r--pylint/reporters/__init__.py6
-rw-r--r--pylint/test/unittest_reporting.py19
3 files changed, 28 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index de3db57..687327d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -92,6 +92,11 @@ ChangeLog for Pylint
of interfaces. One side effect of this change is that ignore-iface-methods
becomes a noop, it's deprecated and it will be removed at some time.
+ * Emit a proper deprecation warning for reporters.BaseReporter.add_message.
+
+ The alternative way is to use handle_message. add_message will be removed in
+ Pylint 1.6.
+
2015-03-14 -- 1.4.3
diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py
index db96cf6..5a70647 100644
--- a/pylint/reporters/__init__.py
+++ b/pylint/reporters/__init__.py
@@ -17,6 +17,8 @@ from __future__ import print_function
import sys
import locale
import os
+import warnings
+
import six
@@ -68,7 +70,9 @@ class BaseReporter(object):
def add_message(self, msg_id, location, msg):
"""Deprecated, do not use."""
- raise NotImplementedError
+ msg = ("This method is deprecated, use handle_message instead. "
+ "It will be removed in Pylint 1.6.")
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
def set_output(self, output=None):
"""set output stream"""
diff --git a/pylint/test/unittest_reporting.py b/pylint/test/unittest_reporting.py
index 03c108e..c98e86b 100644
--- a/pylint/test/unittest_reporting.py
+++ b/pylint/test/unittest_reporting.py
@@ -17,10 +17,12 @@ import unittest
import warnings
import six
-
from logilab.common.ureports import Section
+
+from pylint import __pkginfo__
from pylint.lint import PyLinter
from pylint import checkers
+from pylint.reporters import BaseReporter
from pylint.reporters.text import TextReporter, ParseableTextReporter
from pylint.reporters.html import HTMLReporter
@@ -37,6 +39,21 @@ class PyLinterTC(unittest.TestCase):
checkers.initialize(self.linter)
os.environ.pop('PYLINTRC', None)
+ def test_add_message_is_deprecated(self):
+ if __pkginfo__.numversion > (1, 6, 0):
+ with self.assertRaises(AttributeError):
+ BaseReporter().add_message
+
+ with warnings.catch_warnings(record=True) as cm:
+ warnings.simplefilter("always")
+ BaseReporter().add_message(None, None, None)
+
+ self.assertEqual(len(cm), 1)
+ self.assertIsInstance(cm[0].message, DeprecationWarning)
+ msg = ('This method is deprecated, use handle_message '
+ 'instead. It will be removed in Pylint 1.6.')
+ self.assertEqual(str(cm[0].message), msg)
+
def test_template_option(self):
output = six.StringIO()
self.linter.reporter.set_output(output)