Skip to content

Commit d6b43fe

Browse files
committed
Make client.py typecheck under pyright
1 parent 4aef4bf commit d6b43fe

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ exclude = [
183183
"temporalio/bridge/proto",
184184
"tests/worker/workflow_sandbox/testmodules/proto",
185185
"temporalio/bridge/worker.py",
186-
"temporalio/client.py",
187186
"temporalio/contrib/opentelemetry.py",
188187
"temporalio/converter.py",
189188
"temporalio/testing/_workflow.py",

temporalio/client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import google.protobuf.duration_pb2
3636
import google.protobuf.json_format
3737
import google.protobuf.timestamp_pb2
38-
from typing_extensions import Concatenate, TypedDict
38+
from typing_extensions import Concatenate, Required, TypedDict
3939

4040
import temporalio.api.common.v1
4141
import temporalio.api.enums.v1
@@ -1112,12 +1112,12 @@ async def get_worker_task_reachability(
11121112
class ClientConfig(TypedDict, total=False):
11131113
"""TypedDict of config originally passed to :py:meth:`Client`."""
11141114

1115-
service_client: temporalio.service.ServiceClient
1116-
namespace: str
1117-
data_converter: temporalio.converter.DataConverter
1118-
interceptors: Sequence[Interceptor]
1119-
default_workflow_query_reject_condition: Optional[
1120-
temporalio.common.QueryRejectCondition
1115+
service_client: Required[temporalio.service.ServiceClient]
1116+
namespace: Required[str]
1117+
data_converter: Required[temporalio.converter.DataConverter]
1118+
interceptors: Required[Sequence[Interceptor]]
1119+
default_workflow_query_reject_condition: Required[
1120+
Optional[temporalio.common.QueryRejectCondition]
11211121
]
11221122

11231123

@@ -1797,7 +1797,7 @@ async def execute_update(
17971797
MultiParamSpec, LocalReturnType
17981798
],
17991799
*,
1800-
args: MultiParamSpec.args,
1800+
args: MultiParamSpec.args, # pyright: ignore
18011801
id: Optional[str] = None,
18021802
rpc_metadata: Mapping[str, str] = {},
18031803
rpc_timeout: Optional[timedelta] = None,
@@ -1906,7 +1906,7 @@ async def start_update(
19061906
MultiParamSpec, LocalReturnType
19071907
],
19081908
*,
1909-
args: MultiParamSpec.args,
1909+
args: MultiParamSpec.args, # pyright: ignore
19101910
wait_for_stage: WorkflowUpdateStage,
19111911
id: Optional[str] = None,
19121912
rpc_metadata: Mapping[str, str] = {},
@@ -3489,7 +3489,7 @@ class ScheduleOverlapPolicy(IntEnum):
34893489
"""
34903490

34913491
SKIP = int(
3492-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_SKIP
3492+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_SKIP # pyright: ignore
34933493
)
34943494
"""Don't start anything.
34953495
@@ -3498,7 +3498,7 @@ class ScheduleOverlapPolicy(IntEnum):
34983498
"""
34993499

35003500
BUFFER_ONE = int(
3501-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_BUFFER_ONE
3501+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_BUFFER_ONE # pyright: ignore
35023502
)
35033503
"""Start the workflow again soon as the current one completes, but only
35043504
buffer one start in this way.
@@ -3509,25 +3509,25 @@ class ScheduleOverlapPolicy(IntEnum):
35093509
"""
35103510

35113511
BUFFER_ALL = int(
3512-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_BUFFER_ALL
3512+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_BUFFER_ALL # pyright: ignore
35133513
)
35143514
"""Buffer up any number of starts to all happen sequentially, immediately
35153515
after the running workflow completes."""
35163516

35173517
CANCEL_OTHER = int(
3518-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_CANCEL_OTHER
3518+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_CANCEL_OTHER # pyright: ignore
35193519
)
35203520
"""If there is another workflow running, cancel it, and start the new one
35213521
after the old one completes cancellation."""
35223522

35233523
TERMINATE_OTHER = int(
3524-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_TERMINATE_OTHER
3524+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_TERMINATE_OTHER # pyright: ignore
35253525
)
35263526
"""If there is another workflow running, terminate it and start the new one
35273527
immediately."""
35283528

35293529
ALLOW_ALL = int(
3530-
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_ALLOW_ALL
3530+
temporalio.api.enums.v1.ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_ALLOW_ALL # pyright: ignore
35313531
)
35323532
"""Start any number of concurrent workflows.
35333533

temporalio/worker/_workflow.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88
import os
99
import sys
1010
from datetime import timezone
11-
from threading import get_ident
1211
from types import TracebackType
1312
from typing import (
1413
Callable,
1514
Dict,
1615
List,
17-
Literal,
1816
MutableMapping,
1917
Optional,
2018
Sequence,
2119
Set,
22-
Tuple,
2320
Type,
2421
)
2522

temporalio/worker/_workflow_instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ async def run_update() -> None:
587587
else:
588588
self._current_activation_error = err
589589
return
590-
except BaseException as err:
590+
except BaseException:
591591
if self._deleting:
592592
if LOG_IGNORE_DURING_DELETE:
593593
logger.debug(
@@ -883,7 +883,7 @@ async def run_workflow(input: ExecuteWorkflowInput) -> None:
883883
)
884884
self._primary_task = self.create_task(
885885
self._run_top_level_workflow_function(run_workflow(input)),
886-
name=f"run",
886+
name="run",
887887
)
888888

889889
def _apply_update_random_seed(

tests/helpers/external_coroutine.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
File used in conjunction with external_stack_trace.py to test filenames in multi-file workflows.
33
"""
44

5-
from asyncio import sleep
6-
75
from temporalio import workflow
86

97

10-
async def never_completing_coroutine(status) -> None:
8+
async def never_completing_coroutine(status: list[str]) -> None:
119
status[0] = "waiting" # external coroutine test
1210
await workflow.wait_condition(lambda: False)
1311

1412

15-
async def wait_on_timer(status) -> None:
13+
async def wait_on_timer(status: list[str]) -> None:
1614
status[0] = "waiting" # multifile test
1715
print("Coroutine executed, waiting.")
1816
await workflow.wait_condition(lambda: False)

0 commit comments

Comments
 (0)