From 6a15bd00b52d44830cda9eb73411423210344fc3 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Fri, 26 Feb 2016 08:21:09 -0600 Subject: [PATCH] Store plugin parameters on the plugin itself This allows us to access these from the checker module as well. --- flake8/plugins/manager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flake8/plugins/manager.py b/flake8/plugins/manager.py index aba5f16..c453dbe 100644 --- a/flake8/plugins/manager.py +++ b/flake8/plugins/manager.py @@ -35,6 +35,7 @@ class Plugin(object): self.name = name self.entry_point = entry_point self._plugin = None + self._parameters = None def __repr__(self): """Provide an easy to read description of the current plugin.""" @@ -42,6 +43,13 @@ class Plugin(object): self.name, self.entry_point ) + @property + def parameters(self): + """List of arguments that need to be passed to the plugin.""" + if self._parameters is None: + self._parameters = utils.parameters_for(self) + return self._parameters + @property def plugin(self): """The loaded (and cached) plugin associated with the entry-point. @@ -303,8 +311,7 @@ class Checkers(PluginTypeManager): Find all checker plugins that are expecting a specific argument. """ for plugin in self.plugins.values(): - parameters = utils.parameters_for(plugin) - if argument_name == parameters[0]: + if argument_name == plugin.parameters[0]: yield plugin @property