Skip to content

Commit 54487f5

Browse files
committed
use older-style union syntax for Python 3.9 compatability
1 parent fa9b1b2 commit 54487f5

File tree

8 files changed

+138
-138
lines changed

8 files changed

+138
-138
lines changed

temporalio/bridge/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from dataclasses import dataclass
99
from datetime import timedelta
10-
from typing import Mapping, Optional, Tuple, Type, TypeVar
10+
from typing import Mapping, Optional, Tuple, Type, TypeVar, Union
1111

1212
import google.protobuf.message
1313

@@ -59,7 +59,7 @@ class ClientConfig:
5959
"""Python representation of the Rust struct for configuring the client."""
6060

6161
target_url: str
62-
metadata: Mapping[str, str | bytes]
62+
metadata: Mapping[str, Union[str, bytes]]
6363
api_key: Optional[str]
6464
identity: str
6565
tls_config: Optional[ClientTlsConfig]
@@ -77,7 +77,7 @@ class RpcCall:
7777
rpc: str
7878
req: bytes
7979
retry: bool
80-
metadata: Mapping[str, str | bytes]
80+
metadata: Mapping[str, Union[str, bytes]]
8181
timeout_millis: Optional[int]
8282

8383

@@ -108,7 +108,7 @@ def __init__(
108108
self._runtime = runtime
109109
self._ref = ref
110110

111-
def update_metadata(self, metadata: Mapping[str, str | bytes]) -> None:
111+
def update_metadata(self, metadata: Mapping[str, Union[str, bytes]]) -> None:
112112
"""Update underlying metadata on Core client."""
113113
self._ref.update_metadata(metadata)
114114

@@ -124,7 +124,7 @@ async def call(
124124
req: google.protobuf.message.Message,
125125
resp_type: Type[ProtoMessage],
126126
retry: bool,
127-
metadata: Mapping[str, str | bytes],
127+
metadata: Mapping[str, Union[str, bytes]],
128128
timeout: Optional[timedelta],
129129
) -> ProtoMessage:
130130
"""Make RPC call using SDK Core."""

temporalio/client.py

Lines changed: 111 additions & 111 deletions
Large diffs are not rendered by default.

temporalio/nexus/_operation_context.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async def start_workflow(
244244
start_delay: Optional[timedelta] = None,
245245
start_signal: Optional[str] = None,
246246
start_signal_args: Sequence[Any] = [],
247-
rpc_metadata: Mapping[str, str | bytes] = {},
247+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
248248
rpc_timeout: Optional[timedelta] = None,
249249
request_eager_start: bool = False,
250250
priority: temporalio.common.Priority = temporalio.common.Priority.default,
@@ -279,7 +279,7 @@ async def start_workflow(
279279
start_delay: Optional[timedelta] = None,
280280
start_signal: Optional[str] = None,
281281
start_signal_args: Sequence[Any] = [],
282-
rpc_metadata: Mapping[str, str | bytes] = {},
282+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
283283
rpc_timeout: Optional[timedelta] = None,
284284
request_eager_start: bool = False,
285285
priority: temporalio.common.Priority = temporalio.common.Priority.default,
@@ -316,7 +316,7 @@ async def start_workflow(
316316
start_delay: Optional[timedelta] = None,
317317
start_signal: Optional[str] = None,
318318
start_signal_args: Sequence[Any] = [],
319-
rpc_metadata: Mapping[str, str | bytes] = {},
319+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
320320
rpc_timeout: Optional[timedelta] = None,
321321
request_eager_start: bool = False,
322322
priority: temporalio.common.Priority = temporalio.common.Priority.default,
@@ -353,7 +353,7 @@ async def start_workflow(
353353
start_delay: Optional[timedelta] = None,
354354
start_signal: Optional[str] = None,
355355
start_signal_args: Sequence[Any] = [],
356-
rpc_metadata: Mapping[str, str | bytes] = {},
356+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
357357
rpc_timeout: Optional[timedelta] = None,
358358
request_eager_start: bool = False,
359359
priority: temporalio.common.Priority = temporalio.common.Priority.default,
@@ -388,7 +388,7 @@ async def start_workflow(
388388
start_delay: Optional[timedelta] = None,
389389
start_signal: Optional[str] = None,
390390
start_signal_args: Sequence[Any] = [],
391-
rpc_metadata: Mapping[str, str | bytes] = {},
391+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
392392
rpc_timeout: Optional[timedelta] = None,
393393
request_eager_start: bool = False,
394394
priority: temporalio.common.Priority = temporalio.common.Priority.default,

temporalio/service.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ConnectConfig:
143143
tls: Union[bool, TLSConfig] = False
144144
retry_config: Optional[RetryConfig] = None
145145
keep_alive_config: Optional[KeepAliveConfig] = KeepAliveConfig.default
146-
rpc_metadata: Mapping[str, str | bytes] = field(default_factory=dict)
146+
rpc_metadata: Mapping[str, Union[str, bytes]] = field(default_factory=dict)
147147
identity: str = ""
148148
lazy: bool = False
149149
runtime: Optional[temporalio.runtime.Runtime] = None
@@ -232,7 +232,7 @@ async def check_health(
232232
*,
233233
service: str = "temporal.api.workflowservice.v1.WorkflowService",
234234
retry: bool = False,
235-
metadata: Mapping[str, str | bytes] = {},
235+
metadata: Mapping[str, Union[str, bytes]] = {},
236236
timeout: Optional[timedelta] = None,
237237
) -> bool:
238238
"""Check whether the WorkflowService is up.
@@ -264,7 +264,7 @@ def worker_service_client(self) -> _BridgeServiceClient:
264264
raise NotImplementedError
265265

266266
@abstractmethod
267-
def update_rpc_metadata(self, metadata: Mapping[str, str | bytes]) -> None:
267+
def update_rpc_metadata(self, metadata: Mapping[str, Union[str, bytes]]) -> None:
268268
"""Update service client's RPC metadata."""
269269
raise NotImplementedError
270270

@@ -282,7 +282,7 @@ async def _rpc_call(
282282
*,
283283
service: str,
284284
retry: bool,
285-
metadata: Mapping[str, str | bytes],
285+
metadata: Mapping[str, Union[str, bytes]],
286286
timeout: Optional[timedelta],
287287
) -> ServiceResponse:
288288
raise NotImplementedError
@@ -1257,7 +1257,7 @@ async def __call__(
12571257
req: ServiceRequest,
12581258
*,
12591259
retry: bool = False,
1260-
metadata: Mapping[str, str | bytes] = {},
1260+
metadata: Mapping[str, Union[str, bytes]] = {},
12611261
timeout: Optional[timedelta] = None,
12621262
) -> ServiceResponse:
12631263
"""Invoke underlying client with the given request.
@@ -1316,7 +1316,7 @@ def worker_service_client(self) -> _BridgeServiceClient:
13161316
"""Underlying service client."""
13171317
return self
13181318

1319-
def update_rpc_metadata(self, metadata: Mapping[str, str | bytes]) -> None:
1319+
def update_rpc_metadata(self, metadata: Mapping[str, Union[str, bytes]]) -> None:
13201320
"""Update Core client metadata."""
13211321
# Mutate the bridge config and then only mutate the running client
13221322
# metadata if already connected
@@ -1340,7 +1340,7 @@ async def _rpc_call(
13401340
*,
13411341
service: str,
13421342
retry: bool,
1343-
metadata: Mapping[str, str | bytes],
1343+
metadata: Mapping[str, Union[str, bytes]],
13441344
timeout: Optional[timedelta],
13451345
) -> ServiceResponse:
13461346
global LOG_PROTOS

temporalio/testing/_workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def start_local(
8484
temporalio.common.QueryRejectCondition
8585
] = None,
8686
retry_config: Optional[temporalio.client.RetryConfig] = None,
87-
rpc_metadata: Mapping[str, str | bytes] = {},
87+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
8888
identity: Optional[str] = None,
8989
tls: bool | temporalio.client.TLSConfig = False,
9090
ip: str = "127.0.0.1",
@@ -244,7 +244,7 @@ async def start_time_skipping(
244244
temporalio.common.QueryRejectCondition
245245
] = None,
246246
retry_config: Optional[temporalio.client.RetryConfig] = None,
247-
rpc_metadata: Mapping[str, str | bytes] = {},
247+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
248248
identity: Optional[str] = None,
249249
port: Optional[int] = None,
250250
download_dest_dir: Optional[str] = None,
@@ -573,7 +573,7 @@ async def result(
573573
self,
574574
*,
575575
follow_runs: bool = True,
576-
rpc_metadata: Mapping[str, str | bytes] = {},
576+
rpc_metadata: Mapping[str, Union[str, bytes]] = {},
577577
rpc_timeout: Optional[timedelta] = None,
578578
) -> Any:
579579
async with self.env.time_skipping_unlocked():

tests/api/test_grpc_stub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import timedelta
2-
from typing import Mapping, Any, cast
2+
from typing import Mapping, Any, cast, Union
33
import pytest
44
import re
55

@@ -38,9 +38,9 @@ def assert_time_remaining(context: ServicerContext, expected: int) -> None:
3838
class SimpleWorkflowServer(WorkflowServiceServicer):
3939
def __init__(self) -> None:
4040
super().__init__()
41-
self.last_metadata: Mapping[str, str | bytes] = {}
41+
self.last_metadata: Mapping[str, Union[str, bytes]] = {}
4242

43-
def assert_last_metadata(self, expected: Mapping[str, str | bytes]) -> None:
43+
def assert_last_metadata(self, expected: Mapping[str, Union[str, bytes]]) -> None:
4444
for k, v in expected.items():
4545
assert self.last_metadata.get(k) == v
4646

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import uuid
66
from datetime import datetime, timedelta, timezone
7-
from typing import Any, List, Mapping, Optional, Tuple, cast
7+
from typing import Any, List, Mapping, Optional, Tuple, cast, Union
88
from unittest import mock
99

1010
import google.protobuf.any_pb2
@@ -324,7 +324,7 @@ async def __call__(
324324
req: temporalio.api.workflowservice.v1.StartWorkflowExecutionRequest,
325325
*,
326326
retry: bool = False,
327-
metadata: Mapping[str, str | bytes] = {},
327+
metadata: Mapping[str, Union[str, bytes]] = {},
328328
timeout: Optional[timedelta] = None,
329329
) -> temporalio.api.workflowservice.v1.StartWorkflowExecutionResponse:
330330
raise self.already_exists_err

tests/worker/test_update_with_start.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from datetime import timedelta
77
from enum import Enum, IntEnum
8-
from typing import Any, Mapping, Optional
8+
from typing import Any, Mapping, Optional, Union
99
from unittest.mock import patch
1010

1111
import temporalio.api.common.v1
@@ -822,7 +822,7 @@ async def __call__(
822822
req: temporalio.api.workflowservice.v1.ExecuteMultiOperationRequest,
823823
*,
824824
retry: bool = False,
825-
metadata: Mapping[str, str | bytes] = {},
825+
metadata: Mapping[str, Union[str, bytes]] = {},
826826
timeout: Optional[timedelta] = None,
827827
) -> temporalio.api.workflowservice.v1.ExecuteMultiOperationResponse:
828828
raise self.empty_details_err

0 commit comments

Comments
 (0)