Skip to content

Commit 6ac6316

Browse files
committed
Upgrade mypy to work with pydantic
1 parent ebfeefa commit 6ac6316

File tree

4 files changed

+53
-37
lines changed

4 files changed

+53
-37
lines changed

poetry.lock

Lines changed: 40 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ temporalio = "^1.10.0"
2222
[tool.poetry.dev-dependencies]
2323
black = "^22.3.0"
2424
isort = "^5.10.1"
25-
mypy = "^0.981"
25+
mypy = "^1.4.1"
2626
pytest = "^7.1.2"
2727
pytest-asyncio = "^0.18.3"
2828
frozenlist = "^1.4.0"
29+
types-pyyaml = "^6.0.12.20241230"
30+
2931

3032
# All sample-specific dependencies are in optional groups below, named after the
3133
# sample they apply to

sentry/interceptor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ async def execute_activity(self, input: ExecuteActivityInput) -> Any:
3737
try:
3838
return await super().execute_activity(input)
3939
except Exception as e:
40-
if len(input.args) == 1 and is_dataclass(input.args[0]):
41-
set_context("temporal.activity.input", asdict(input.args[0]))
40+
if len(input.args) == 1:
41+
[arg] = input.args
42+
if is_dataclass(arg) and not isinstance(arg, type):
43+
set_context("temporal.activity.input", asdict(arg))
4244
set_context("temporal.activity.info", activity.info().__dict__)
4345
capture_exception()
4446
raise e
@@ -58,8 +60,10 @@ async def execute_workflow(self, input: ExecuteWorkflowInput) -> Any:
5860
try:
5961
return await super().execute_workflow(input)
6062
except Exception as e:
61-
if len(input.args) == 1 and is_dataclass(input.args[0]):
62-
set_context("temporal.workflow.input", asdict(input.args[0]))
63+
if len(input.args) == 1:
64+
[arg] = input.args
65+
if is_dataclass(arg) and not isinstance(arg, type):
66+
set_context("temporal.workflow.input", asdict(arg))
6367
set_context("temporal.workflow.info", workflow.info().__dict__)
6468

6569
if not workflow.unsafe.is_replaying():

tests/message_passing/safe_message_handlers/workflow_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ async def test_safe_message_handlers(client: Client, env: WorkflowEnvironment):
7979

8080
await cluster_manager_handle.signal(ClusterManagerWorkflow.shutdown_cluster)
8181

82-
result = await cluster_manager_handle.result()
83-
assert result.num_currently_assigned_nodes == 0
82+
cluster_manager_result = await cluster_manager_handle.result()
83+
assert cluster_manager_result.num_currently_assigned_nodes == 0
8484

8585

8686
async def test_update_idempotency(client: Client, env: WorkflowEnvironment):

0 commit comments

Comments
 (0)