Skip to content

Commit 59d04a6

Browse files
authored
Make client.py typecheck under pyright (#628)
1 parent a18140f commit 59d04a6

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

pyproject.toml

-1
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

+10-11
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] = {},
@@ -3233,7 +3233,7 @@ class ScheduleActionStartWorkflow(ScheduleAction):
32333233
headers: Optional[Mapping[str, temporalio.api.common.v1.Payload]]
32343234

32353235
@staticmethod
3236-
def _from_proto(
3236+
def _from_proto( # pyright: ignore
32373237
info: temporalio.api.workflow.v1.NewWorkflowExecutionInfo, # type: ignore[override]
32383238
) -> ScheduleActionStartWorkflow:
32393239
return ScheduleActionStartWorkflow("<unset>", raw_info=info)
@@ -3482,7 +3482,6 @@ async def _to_proto(
34823482
return action
34833483

34843484

3485-
@dataclass
34863485
class ScheduleOverlapPolicy(IntEnum):
34873486
"""Controls what happens when a workflow would be started by a schedule but
34883487
one is already running.

temporalio/worker/_workflow.py

-3
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

+2-2
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
File used in conjunction with external_stack_trace.py to test filenames in multi-file workflows.
33
"""
44

5-
from asyncio import sleep
5+
from typing import List
66

77
from temporalio import workflow
88

99

10-
async def never_completing_coroutine(status) -> None:
10+
async def never_completing_coroutine(status: List[str]) -> None:
1111
status[0] = "waiting" # external coroutine test
1212
await workflow.wait_condition(lambda: False)
1313

1414

15-
async def wait_on_timer(status) -> None:
15+
async def wait_on_timer(status: List[str]) -> None:
1616
status[0] = "waiting" # multifile test
1717
print("Coroutine executed, waiting.")
1818
await workflow.wait_condition(lambda: False)

0 commit comments

Comments
 (0)