Skip to content

Commit c618ee2

Browse files
vondravlclaude
andcommitted
chore(gooddata-sdk): make UpsertOutcome str() match StrEnum
str(UpsertOutcome.CREATED) returned "UpsertOutcome.CREATED"; with __str__ = str.__str__ it returns "created", so swapping the base class for StrEnum once py3.10 support is dropped is a no-op for callers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d9fb3ba commit c618ee2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/gooddata-sdk/src/gooddata_sdk/catalog/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ class UpsertOutcome(str, Enum):
1818

1919
CREATED = "created"
2020
UPDATED = "updated"
21+
22+
# Match StrEnum's str() (the value, not "UpsertOutcome.CREATED") so moving
23+
# to StrEnum once py3.10 support is dropped is a no-op for callers.
24+
__str__ = str.__str__

packages/gooddata-sdk/tests/catalog/test_upsert_outcome.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ def test_workspace_setting(self):
136136

137137
@pytest.mark.parametrize("outcome", list(UpsertOutcome))
138138
def test_outcome_is_a_plain_string(outcome):
139-
"""The str mixin keeps the value usable in logs and comparisons on py3.10."""
139+
"""The str mixin keeps the value usable in logs and comparisons on py3.10.
140+
141+
The str()/format() assertions pin the `__str__ = str.__str__` override, so
142+
swapping the base for StrEnum once py3.10 is dropped stays a no-op.
143+
"""
140144
assert isinstance(outcome, str)
141145
assert outcome == outcome.value
146+
assert str(outcome) == outcome.value
147+
assert f"{outcome}" == outcome.value

0 commit comments

Comments
 (0)