From d929dd57cb80a31f151535d32f7593d95c4e80ee Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 10 May 2016 20:12:38 -0500 Subject: [PATCH] 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. --- flake8/plugins/manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flake8/plugins/manager.py b/flake8/plugins/manager.py index 56ee813..fe51391 100644 --- a/flake8/plugins/manager.py +++ b/flake8/plugins/manager.py @@ -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."""