diff options
author | Michal Nowikowski <godfryd@gmail.com> | 2015-01-07 05:47:06 +0100 |
---|---|---|
committer | Michal Nowikowski <godfryd@gmail.com> | 2015-01-07 05:47:06 +0100 |
commit | 968ed3dc3565f42caf7250b76af05a3743860bce (patch) | |
tree | a087d366c54f565303e8e5eaca7a5a5cfb5dd1bc | |
parent | 255d5c41d34cbb5d2d076b2beab2c81b47531253 (diff) | |
download | pylint-968ed3dc3565f42caf7250b76af05a3743860bce.tar.gz |
Fixed passing configuration from master linter to sublinters. Closes issue #374.
-rw-r--r-- | lint.py | 38 | ||||
-rw-r--r-- | utils.py | 4 |
2 files changed, 20 insertions, 22 deletions
@@ -206,25 +206,17 @@ if multiprocessing is not None: # Load command line plugins. # TODO linter.load_plugin_modules(self._plugins) - linter.disable('pointless-except') - linter.disable('suppressed-message') - linter.disable('useless-suppression') - - # TODO(cpopa): the sub-linters will not know all the options - # because they are not available here, as they are patches to - # PyLinter options. The following is just a hack to handle - # just a part of the options available in the Run class. - - if 'disable_msg' in config: - # Disable everything again. We don't have access - # to the original linter though. - for msgid in config['disable_msg']: - linter.disable(msgid) - for key in set(config) - set(dict(linter.options)): - del config[key] - - config['jobs'] = 1 # Child does not parallelize any further. - linter.load_configuration(**config) + # this flags should not be propagated + filter_options = {'symbols', 'include-ids', 'rcfile', 'init-hook', 'help-msg', 'list-msgs', 'list-conf-levels', + 'full-documentation', 'generate-rcfile', 'generate-man', 'profile', 'long-help', 'py3k', 'errors-only'} + sublinter_config = {} + for opt_providers in six.itervalues(linter._all_options): + for optname, _ in opt_providers.options: + if optname not in filter_options: + sublinter_config[optname] = config[optname] + + sublinter_config['jobs'] = 1 # Child does not parallelize any further. + linter.load_configuration(**sublinter_config) linter.set_reporter(reporters.CollectingReporter()) # Run the checks. @@ -501,12 +493,14 @@ class PyLinter(configuration.OptionsManagerMixIn, meth(_id, ignore_unknown=True) else: meth(value) + return # no need to call set_option, disable/enable methods do it elif optname == 'output-format': self._reporter_name = value # If the reporters are already available, load # the reporter class. if self._reporters: self._load_reporter() + try: checkers.BaseTokenChecker.set_option(self, optname, value, action, optdict) @@ -701,7 +695,11 @@ class PyLinter(configuration.OptionsManagerMixIn, def _parallel_task(self, files_or_modules): # Prepare configuration for child linters. - config = vars(self.config) + config = {} + for opt_providers in six.itervalues(self._all_options): + for optname, optdict, val in opt_providers.options_and_values(): + config[optname] = configuration.format_option_value(optdict, val) + childs = [] manager = multiprocessing.Manager() # pylint: disable=no-member tasks_queue = manager.Queue() # pylint: disable=no-member @@ -270,8 +270,8 @@ class MessagesHandlerMixIn(object): msgs = self._msgs_state msgs[msg.msgid] = False # sync configuration object - self.config.disable_msg = [mid for mid, val in six.iteritems(msgs) - if not val] + self.config.disable = [mid for mid, val in six.iteritems(msgs) + if not val] def enable(self, msgid, scope='package', line=None, ignore_unknown=False): """reenable message of the given id""" |