Skip to content

Commit aad33c2

Browse files
committed
Rename utilities
1 parent cea3f02 commit aad33c2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

temporalio/nexus/_link_conversion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _query_params_from_event_reference(
9090
) -> str:
9191
event_type_name = temporalio.api.enums.v1.EventType.Name(event_ref.event_type)
9292
if event_type_name.startswith("EVENT_TYPE_"):
93-
event_type_name = _constant_case_to_pascal_case(
93+
event_type_name = _event_type_constant_case_to_pascal_case(
9494
event_type_name.removeprefix("EVENT_TYPE_")
9595
)
9696
return urllib.parse.urlencode(
@@ -116,7 +116,7 @@ def _event_reference_from_query_params(
116116
if raw_event_type_name.startswith("EVENT_TYPE_"):
117117
event_type_name = raw_event_type_name
118118
elif re.match("[A-Z][a-z]", raw_event_type_name):
119-
event_type_name = "EVENT_TYPE_" + _pascal_case_to_constant_case(
119+
event_type_name = "EVENT_TYPE_" + _event_type_pascal_case_to_constant_case(
120120
raw_event_type_name
121121
)
122122
else:
@@ -137,19 +137,19 @@ def _event_reference_from_query_params(
137137
)
138138

139139

140-
def _constant_case_to_pascal_case(s: str) -> str:
140+
def _event_type_constant_case_to_pascal_case(s: str) -> str:
141141
"""Convert a CONSTANT_CASE string to PascalCase.
142142
143-
>>> _constant_case_to_pascal_case("NEXUS_OPERATION_SCHEDULED")
143+
>>> _event_type_constant_case_to_pascal_case("NEXUS_OPERATION_SCHEDULED")
144144
"NexusOperationScheduled"
145145
"""
146146
return re.sub(r"(\b|_)([a-z])", lambda m: m.groups()[1].upper(), s.lower())
147147

148148

149-
def _pascal_case_to_constant_case(s: str) -> str:
149+
def _event_type_pascal_case_to_constant_case(s: str) -> str:
150150
"""Convert a PascalCase string to CONSTANT_CASE.
151151
152-
>>> _pascal_case_to_constant_case("NexusOperationScheduled")
152+
>>> _event_type_pascal_case_to_constant_case("NexusOperationScheduled")
153153
"NEXUS_OPERATION_SCHEDULED"
154154
"""
155155
return re.sub(r"([^\b])([A-Z])", lambda m: "_".join(m.groups()), s).upper()

tests/nexus/test_workflow_caller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,8 +1277,8 @@ async def test_workflow_run_operation_overloads(
12771277

12781278

12791279
def test_link_conversion_utilities():
1280-
p2c = temporalio.nexus._link_conversion._pascal_case_to_constant_case
1281-
c2p = temporalio.nexus._link_conversion._constant_case_to_pascal_case
1280+
p2c = temporalio.nexus._link_conversion._event_type_pascal_case_to_constant_case
1281+
c2p = temporalio.nexus._link_conversion._event_type_constant_case_to_pascal_case
12821282

12831283
for p, c in [
12841284
("", ""),

0 commit comments

Comments
 (0)