mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 08:04:18 +00:00
Iterate over the checkers fewer times
This commit is contained in:
parent
d8665435a5
commit
15745558c1
1 changed files with 17 additions and 4 deletions
|
|
@ -428,14 +428,27 @@ class Checkers(PluginTypeManager):
|
||||||
yield plugin
|
yield plugin
|
||||||
|
|
||||||
def register_options(self, optmanager):
|
def register_options(self, optmanager):
|
||||||
"""Register all of the checkers' options to the OptionManager."""
|
"""Register all of the checkers' options to the OptionManager.
|
||||||
super(Checkers, self).register_options(optmanager)
|
|
||||||
|
|
||||||
def conditionally_enable(plugin):
|
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 register_and_enable(plugin):
|
||||||
|
call_register_options(plugin)
|
||||||
if plugin.group() is None and not plugin.off_by_default:
|
if plugin.group() is None and not plugin.off_by_default:
|
||||||
plugin.enable(optmanager)
|
plugin.enable(optmanager)
|
||||||
|
|
||||||
list(self.manager.map(conditionally_enable))
|
list(self.manager.map(register_and_enable))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ast_plugins(self):
|
def ast_plugins(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue