From 153ea04e3274cd939901594ab3f41679329c27bd Mon Sep 17 00:00:00 2001 From: Theodore Tucker Date: Sat, 11 Jul 2026 16:57:16 +0100 Subject: [PATCH 1/2] FastEnum: update __repr__ and __str__ to behave like StrEnum This means we can drop the redundant __str__ implementation on the subclass _PipelineSelection. --- src/buildstream/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/buildstream/types.py b/src/buildstream/types.py index 0cc2106b3..a21e1dc29 100644 --- a/src/buildstream/types.py +++ b/src/buildstream/types.py @@ -81,11 +81,14 @@ def __hash__(self): return hash(id(self)) def __str__(self): - return "{}.{}".format(self.__class__.__name__, self.name) + return str(self.value) def __reduce__(self): return self.__class__, (self.value,) + def __repr__(self): + return "<{}.{}: {}>".format(self.__class__.__name__, self.name, self.value) + class CoreWarnings: """CoreWarnings() @@ -307,9 +310,6 @@ class _PipelineSelection(FastEnum): # including the targets RUN = "run" - def __str__(self): - return str(self.value) - # _ProjectInformation() # From 7967a1613897bba862f94fe9b134137d9af9c04b Mon Sep 17 00:00:00 2001 From: Theodore Tucker Date: Sat, 11 Jul 2026 17:00:00 +0100 Subject: [PATCH 2/2] cli: stringify FastEnum's passed as Click defaults This should mean the StrEnum-style repr is used by sphinx-click when rendering the default in documentation, resulting in `all` rather than ``. --- src/buildstream/_frontend/cli.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index e9e6ddfb9..b6d8a649d 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -553,7 +553,7 @@ def build( @click.option( "--deps", "-d", - default=_PipelineSelection.ALL, + default=str(_PipelineSelection.ALL), show_default=True, type=FastEnumType( _PipelineSelection, @@ -814,7 +814,7 @@ def source(): @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -887,7 +887,7 @@ def source_fetch(app, elements, deps, except_, source_remotes, ignore_project_so @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -960,7 +960,7 @@ def source_push(app, elements, deps, except_, source_remotes, ignore_project_sou @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1015,7 +1015,7 @@ def source_track(app, elements, deps, except_, cross_junctions): @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1296,7 +1296,7 @@ def artifact(): @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1339,7 +1339,7 @@ def artifact_show(app, deps, artifact_remotes, ignore_project_artifact_remotes, @click.option( "--deps", "-d", - default=_PipelineSelection.RUN, + default=str(_PipelineSelection.RUN), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1464,7 +1464,7 @@ def artifact_checkout( @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1533,7 +1533,7 @@ def artifact_pull(app, deps, artifact_remotes, ignore_project_artifact_remotes, @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection, @@ -1673,7 +1673,7 @@ def artifact_list_contents(app, artifacts, long_): @click.option( "--deps", "-d", - default=_PipelineSelection.NONE, + default=str(_PipelineSelection.NONE), show_default=True, type=FastEnumType( _PipelineSelection,