summaryrefslogtreecommitdiff
path: root/pylint/lint.py
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-02-28 19:13:33 +0200
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-02-28 19:13:33 +0200
commite6ae438fd29d54ec6aca84f750c55b58da998151 (patch)
treea19c977c90d39146381465c994f7281cb5bbf241 /pylint/lint.py
parent97bebf6a35f0581491f261e922c8ff0c07cd3eee (diff)
downloadpylint-e6ae438fd29d54ec6aca84f750c55b58da998151.tar.gz
Make the --py3k flag commutative with the -E flag.
Also, this patch fixes the leaks of error messages from the Python 3 checker when the errors mode was activated. Closes issue #437.
Diffstat (limited to 'pylint/lint.py')
-rw-r--r--pylint/lint.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/pylint/lint.py b/pylint/lint.py
index 7274c78..5ac51c2 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -455,6 +455,7 @@ class PyLinter(configuration.OptionsManagerMixIn,
self.register_checker(self)
self._dynamic_plugins = set()
self._python3_porting_mode = False
+ self._error_mode = False
self.load_provider_defaults()
if reporter:
self.set_reporter(reporter)
@@ -583,8 +584,16 @@ class PyLinter(configuration.OptionsManagerMixIn,
def error_mode(self):
"""error mode: enable only errors; no reports, no persistent"""
+ self._error_mode = True
self.disable_noerror_messages()
self.disable('miscellaneous')
+ if self._python3_porting_mode:
+ self.disable('all')
+ for msg_id in self._checker_messages('python3'):
+ if msg_id.startswith('E'):
+ self.enable(msg_id)
+ else:
+ self.disable('python3')
self.set_option('reports', False)
self.set_option('persistent', False)
@@ -592,6 +601,15 @@ class PyLinter(configuration.OptionsManagerMixIn,
"""Disable all other checkers and enable Python 3 warnings."""
self.disable('all')
self.enable('python3')
+ if self._error_mode:
+ # The error mode was activated, using the -E flag.
+ # So we'll need to enable only the errors from the
+ # Python 3 porting checker.
+ for msg_id in self._checker_messages('python3'):
+ if msg_id.startswith('E'):
+ self.enable(msg_id)
+ else:
+ self.disable(msg_id)
self._python3_porting_mode = True
# block level option handling #############################################