mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
Add a property for off-by-default plugins
If a plugin is off-by-default use its entry-point name (as we currently do in flake8 2.x) to add it to the default ignore list.
This commit is contained in:
parent
ccadc09a0e
commit
d929dd57cb
1 changed files with 8 additions and 0 deletions
|
|
@ -108,6 +108,11 @@ class Plugin(object):
|
|||
|
||||
return self._plugin_name
|
||||
|
||||
@property
|
||||
def off_by_default(self):
|
||||
"""Return whether the plugin is ignored by default."""
|
||||
return getattr(self.plugin, 'off_by_default', False)
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
r"""Call the plugin with \*args and \*\*kwargs."""
|
||||
return self.plugin(*args, **kwargs) # pylint: disable=not-callable
|
||||
|
|
@ -181,6 +186,9 @@ class Plugin(object):
|
|||
)
|
||||
add_options(optmanager)
|
||||
|
||||
if self.off_by_default:
|
||||
optmanager.extend_default_ignore([self.name])
|
||||
|
||||
|
||||
class PluginManager(object): # pylint: disable=too-few-public-methods
|
||||
"""Find and manage plugins consistently."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue