diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2016-03-05 16:16:56 +0000 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-03-05 16:21:58 +0000 |
commit | ea650a56a0919df5d563e4b9c0deabef18ca066c (patch) | |
tree | 3f9b8205fb0a506f8c96170e908de14a4594c0d3 | |
parent | 2f0810d8fc0ec4898a1813ca8414dd4c14f8f165 (diff) | |
download | pylint-git-ea650a56a0919df5d563e4b9c0deabef18ca066c.tar.gz |
Use an OrderedDict for storing the configuration elements
This fixes an issue related to impredictible order of the disable / enable
elements from a config file. In certain cases, the disable was coming before
the enable which resulted in classes of errors to be enabled, even though the intention
was to disable them. The best example for this was in the context of running multiple
processes, each one of it having different enables / disables that affected the output.
Close #815
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | pylint/config.py | 8 | ||||
-rw-r--r-- | pylint/lint.py | 4 |
3 files changed, 18 insertions, 4 deletions
@@ -7,6 +7,16 @@ ChangeLog for Pylint Close #776. + * Use an OrderedDict for storing the configuration elements + + This fixes an issue related to impredictible order of the disable / enable + elements from a config file. In certain cases, the disable was coming before + the enable which resulted in classes of errors to be enabled, even though the intention + was to disable them. The best example for this was in the context of running multiple + processes, each one of it having different enables / disables that affected the output. + + Close #815 + * Don't consider bare and broad except handlers as ignoring NameError, AttributeError and similar exceptions, in the context of checkers for these issues. diff --git a/pylint/config.py b/pylint/config.py index d0728af81..2ef658377 100644 --- a/pylint/config.py +++ b/pylint/config.py @@ -26,6 +26,7 @@ from __future__ import print_function # need a cleanup. It could be completely reengineered as well. import contextlib +import collections import copy import optparse import os @@ -437,7 +438,7 @@ class OptionsManagerMixIn(object): # list of registered options providers self.options_providers = [] # dictionary associating option name to checker - self._all_options = {} + self._all_options = collections.OrderedDict() self._short_options = {} self._nocallback_options = {} self._mygroups = {} @@ -640,7 +641,10 @@ class OptionsManagerMixIn(object): def load_configuration(self, **kwargs): """override configuration according to given parameters""" - for opt, opt_value in kwargs.items(): + return self.load_configuration_from_config(kwargs) + + def load_configuration_from_config(self, config): + for opt, opt_value in config.items(): opt = opt.replace('_', '-') provider = self._all_options[opt] provider.set_option(opt, opt_value) diff --git a/pylint/lint.py b/pylint/lint.py index 2eb9439ea..b51fe38d6 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -226,7 +226,7 @@ if multiprocessing is not None: if self._plugins: linter.load_plugin_modules(self._plugins) - linter.load_configuration(**self._config) + linter.load_configuration_from_config(self._config) linter.set_reporter(reporters.CollectingReporter()) # Enable the Python 3 checker mode. This option is @@ -737,7 +737,7 @@ class PyLinter(config.OptionsManagerMixIn, self._parallel_check(files_or_modules) def _get_jobs_config(self): - child_config = {} + child_config = collections.OrderedDict() filter_options = {'symbols', 'include-ids', 'long-help'} filter_options.update((opt_name for opt_name, _ in self._external_opts)) for opt_providers in six.itervalues(self._all_options): |