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:
Ian Cordasco 2016-05-10 20:12:38 -05:00
parent ccadc09a0e
commit d929dd57cb

View file

@ -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."""