diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-28 20:27:29 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-28 20:27:29 -0500 |
| commit | 15745558c17fa9732c015f0f4e7fd9386519a70c (patch) | |
| tree | 8173b30697c9becb8c8c61c7de8693d3efae0ed6 /src/flake8/plugins | |
| parent | d8665435a5067a19d52d9e4ed242356fbdfd1ccf (diff) | |
| download | flake8-15745558c17fa9732c015f0f4e7fd9386519a70c.tar.gz | |
Iterate over the checkers fewer times
Diffstat (limited to 'src/flake8/plugins')
| -rw-r--r-- | src/flake8/plugins/manager.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/flake8/plugins/manager.py b/src/flake8/plugins/manager.py index 5d9e52b..a64545a 100644 --- a/src/flake8/plugins/manager.py +++ b/src/flake8/plugins/manager.py @@ -428,14 +428,27 @@ class Checkers(PluginTypeManager): yield plugin def register_options(self, optmanager): - """Register all of the checkers' options to the OptionManager.""" - super(Checkers, self).register_options(optmanager) + """Register all of the checkers' options to the OptionManager. + + This also ensures that plugins that are not part of a group and are + enabled by default are enabled on the option manager. + """ + # NOTE(sigmavirus24) We reproduce a little of + # PluginTypeManager.register_options to reduce the number of times + # that we loop over the list of plugins. Instead of looping twice, + # option registration and enabling the plugin, we loop once with one + # function to map over the plugins. + self.load_plugins() + call_register_options = self._generate_call_function( + 'register_options', optmanager, + ) - def conditionally_enable(plugin): + def register_and_enable(plugin): + call_register_options(plugin) if plugin.group() is None and not plugin.off_by_default: plugin.enable(optmanager) - list(self.manager.map(conditionally_enable)) + list(self.manager.map(register_and_enable)) @property def ast_plugins(self): |
