mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +00:00
Store plugin parameters on the plugin itself
This allows us to access these from the checker module as well.
This commit is contained in:
parent
62a78f4a97
commit
6a15bd00b5
1 changed files with 9 additions and 2 deletions
|
|
@ -35,6 +35,7 @@ class Plugin(object):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.entry_point = entry_point
|
self.entry_point = entry_point
|
||||||
self._plugin = None
|
self._plugin = None
|
||||||
|
self._parameters = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Provide an easy to read description of the current plugin."""
|
"""Provide an easy to read description of the current plugin."""
|
||||||
|
|
@ -42,6 +43,13 @@ class Plugin(object):
|
||||||
self.name, self.entry_point
|
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
|
@property
|
||||||
def plugin(self):
|
def plugin(self):
|
||||||
"""The loaded (and cached) plugin associated with the entry-point.
|
"""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.
|
Find all checker plugins that are expecting a specific argument.
|
||||||
"""
|
"""
|
||||||
for plugin in self.plugins.values():
|
for plugin in self.plugins.values():
|
||||||
parameters = utils.parameters_for(plugin)
|
if argument_name == plugin.parameters[0]:
|
||||||
if argument_name == parameters[0]:
|
|
||||||
yield plugin
|
yield plugin
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue