Constrain our search for plugin type

Flake8 has previously only ever relied on the first member of the
parameters list to determine what kind of check it is using. As such,
we constrain ourselves to just that parameter when checking and add
properties for ast and logical line checks.
This commit is contained in:
Ian Cordasco 2016-02-23 23:25:12 -06:00
parent 24d2689a05
commit cd18b9f175

View file

@ -304,9 +304,27 @@ class Checkers(PluginTypeManager):
"""
for plugin in self.plugins.values():
parameters = utils.parameters_for(plugin)
if argument_name in parameters:
if argument_name == parameters[0]:
yield plugin
@property
def ast_plugins(self):
"""List of plugins that expect the AST tree."""
plugins = getattr(self, '_ast_plugins', [])
if not plugins:
plugins = list(self.checks_expecting('tree'))
self._ast_plugins = plugins
return plugins
@property
def logical_line_plugins(self):
"""List of plugins that expect the logical lines."""
plugins = getattr(self, '_logical_line_plugins', [])
if not plugins:
plugins = list(self.checks_expecting('logical_line'))
self._logical_line_plugins = plugins
return plugins
@property
def physical_line_plugins(self):
"""List of plugins that expect the physical lines."""