summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-02-24 11:11:51 +0200
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-02-24 11:11:51 +0200
commitab0e6ff678fddd8615f11991945bf3be6e6c09e2 (patch)
tree5f0c941d4bb0d82d987c25ba1ca26230caaf053a
parente8cb5a7a24e03c33b6aa6c473fd91eae7daf857d (diff)
downloadpylint-ab0e6ff678fddd8615f11991945bf3be6e6c09e2.tar.gz
Support for combining the Python 3 checker mode with the --jobs flag.
This patch makes sure that --py3k and --jobs flags can be combined together. It introduces a new method in lint.PyLinter, called set_python3_porting_mode, which will setup a new flag inside the linter, passed down to child linters when they are created. Closes issue #467.
-rw-r--r--ChangeLog3
-rw-r--r--pylint/lint.py20
-rw-r--r--pylint/test/test_self.py6
3 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c361c10..ff1b671 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,9 @@ ChangeLog for Pylint
`type(x) == Y` instead of `isinstance(x, Y)`. Patch by Chris Rebert.
Closes issue #299.
+ * Add support for combining the Python 3 checker mode with the --jobs
+ flag (--py3k and --jobs). Closes issue #467.
+
2015-01-16 -- 1.4.1
diff --git a/pylint/lint.py b/pylint/lint.py
index b0f7cc3..7274c78 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -208,6 +208,8 @@ if multiprocessing is not None:
tasks_queue, results_queue, self._config = self._args # pylint: disable=no-member
self._config["jobs"] = 1 # Child does not parallelize any further.
+ self._python3_porting_mode = self._config.pop(
+ 'python3_porting_mode', None)
# Run linter for received files/modules.
for file_or_module in iter(tasks_queue.get, 'STOP'):
@@ -230,6 +232,13 @@ if multiprocessing is not None:
linter.load_configuration(**self._config)
linter.set_reporter(reporters.CollectingReporter())
+ # Enable the Python 3 checker mode. This option is
+ # passed down from the parent linter up to here, since
+ # the Python 3 porting flag belongs to the Run class,
+ # instead of the Linter class.
+ if self._python3_porting_mode:
+ linter.python3_porting_mode()
+
# Run the checks.
linter.check(file_or_module)
@@ -445,6 +454,7 @@ class PyLinter(configuration.OptionsManagerMixIn,
)
self.register_checker(self)
self._dynamic_plugins = set()
+ self._python3_porting_mode = False
self.load_provider_defaults()
if reporter:
self.set_reporter(reporter)
@@ -578,6 +588,12 @@ class PyLinter(configuration.OptionsManagerMixIn,
self.set_option('reports', False)
self.set_option('persistent', False)
+ def python3_porting_mode(self):
+ """Disable all other checkers and enable Python 3 warnings."""
+ self.disable('all')
+ self.enable('python3')
+ self._python3_porting_mode = True
+
# block level option handling #############################################
#
# see func_block_disable_msg.py test case for expected behaviour
@@ -705,6 +721,7 @@ class PyLinter(configuration.OptionsManagerMixIn,
for optname, optdict, val in opt_providers.options_and_values():
if optname not in filter_options:
config[optname] = configuration.format_option_value(optdict, val)
+ config['python3_porting_mode'] = self._python3_porting_mode
childs = []
manager = multiprocessing.Manager() # pylint: disable=no-member
@@ -1323,8 +1340,7 @@ group are mutually exclusive.'),
def cb_python3_porting_mode(self, *args, **kwargs):
"""Activate only the python3 porting checker."""
- self.linter.disable('all')
- self.linter.enable('python3')
+ self.linter.python3_porting_mode()
def cb_list_confidence_levels(option, optname, value, parser):
diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py
index e94d958..1734889 100644
--- a/pylint/test/test_self.py
+++ b/pylint/test/test_self.py
@@ -147,6 +147,12 @@ class RunTC(unittest.TestCase):
'--py3k'],
code=rc_code)
+ def test_py3k_jobs_option(self):
+ rc_code = 2 if six.PY2 else 0
+ self._runtest([join(HERE, 'functional', 'unpacked_exceptions.py'),
+ '--py3k', '-j 2'],
+ code=rc_code)
+
if __name__ == '__main__':
unittest.main()