Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create exactly one associated subsystem per checkstyle plugin #6634

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,6 +7,7 @@
import json

from pants.subsystem.subsystem import Subsystem
from pants.util.memo import memoized


class PluginSubsystemBase(Subsystem):
Expand All @@ -28,7 +29,17 @@ def options_blob(self):
return json.dumps(options_dict) if options_dict else None


@memoized
def default_subsystem_for_plugin(plugin_type):
"""Create a singleton PluginSubsystemBase subclass for the given plugin type.

The singleton enforcement is useful in cases where dependent Tasks are installed multiple times,
to avoid creating duplicate types which would have option scope collisions.

:param plugin_type: A CheckstylePlugin subclass.
:type: :class:`pants.contrib.python.checks.checker.common.CheckstylePlugin`
:rtype: :class:`pants.contrib.python.checks.tasks.checkstyle.plugin_subsystem_base.PluginSubsystemBase`
"""
return type(str('{}Subsystem'.format(plugin_type.__name__)),
(PluginSubsystemBase,),
{
Expand Down