From cd18b9f175a3a73b03f58d4db7fd789c48c671bb Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 23 Feb 2016 23:25:12 -0600 Subject: [PATCH] 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. --- flake8/plugins/manager.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/flake8/plugins/manager.py b/flake8/plugins/manager.py index 21639f9..05e5e2b 100644 --- a/flake8/plugins/manager.py +++ b/flake8/plugins/manager.py @@ -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."""