diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-31 00:16:17 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-31 00:16:17 +0300 |
commit | 63a8818f768fed20c661c9575a5b535ff34b5903 (patch) | |
tree | 7ff402c2cfe0af19e7755ca9cdcde368f5aabcae | |
parent | 40a48529753727b1af6836bef2447c0d413d78b6 (diff) | |
download | pylint-63a8818f768fed20c661c9575a5b535ff34b5903.tar.gz |
--generate-rcfile generates by default human readable symbols for the --disable option. Closes issue #608.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | pylint/test/test_self.py | 18 | ||||
-rw-r--r-- | pylint/utils.py | 16 |
3 files changed, 35 insertions, 2 deletions
@@ -228,6 +228,9 @@ ChangeLog for Pylint * --no-space-check option accepts `empty-line` as a possible option. Closes issue #541. + + * --generate-rcfile generates by default human readable symbols + for the --disable option. Closes issue #608. diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py index 1138d1e..eef267a 100644 --- a/pylint/test/test_self.py +++ b/pylint/test/test_self.py @@ -12,6 +12,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import contextlib +import re import sys import os from os.path import join, dirname, abspath @@ -126,6 +127,23 @@ class RunTC(unittest.TestCase): def test_generate_config_option(self): self._runtest(['--generate-rcfile'], code=0) + def test_generate_config_disable_symbolic_names(self): + # Test that --generate-rcfile puts symbolic names in the --disable + # option. + + out = six.StringIO() + self._run_pylint(["--generate-rcfile", "--rcfile="], out=out) + + output = out.getvalue() + # Get rid of the pesky messages that pylint emits if the + # configuration file is not found. + master = re.search("\[MASTER", output) + out = six.StringIO(output[master.start():]) + parser = six.moves.configparser.RawConfigParser() + parser.readfp(out) + messages = parser.get('MESSAGES CONTROL', 'disable').split(",") + self.assertIn('suppressed-message', messages) + def test_help_message_option(self): self._runtest(['--help-msg', 'W0101'], code=0) diff --git a/pylint/utils.py b/pylint/utils.py index d2c9ed8..8870ec6 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -277,10 +277,22 @@ class MessagesHandlerMixIn(object): else: msgs = self._msgs_state msgs[msg.msgid] = False - # sync configuration object - self.config.disable = [mid for mid, val in six.iteritems(msgs) + # sync configuration object + self.config.disable = [self._message_symbol(mid) + for mid, val in six.iteritems(msgs) if not val] + def _message_symbol(self, msgid): + """Get the message symbol of the given message id + + Return the original message id if the message does not + exist. + """ + try: + return self.msgs_store.check_message_id(msgid).symbol + except UnknownMessage: + return msgid + def enable(self, msgid, scope='package', line=None, ignore_unknown=False): """reenable message of the given id""" assert scope in ('package', 'module') |