Skip to content

Commit 5269ead

Browse files
Fix pyright strict errors: use Enum isinstance checks, add override decorators in tests
1 parent d2b928b commit 5269ead

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/agentex/lib/sdk/state_machine/state_machine.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4+
from enum import Enum
45
from typing import Any, Generic, TypeVar
56

67
from agentex.lib import adk
@@ -140,13 +141,11 @@ def get_lifecycle(self) -> dict[str, Any]:
140141
"waits_for_input": workflow.waits_for_input,
141142
"accepts": list(workflow.accepts),
142143
"transitions": [
143-
t.value if hasattr(t, "value") else str(t)
144+
t.value if isinstance(t, Enum) else str(t)
144145
for t in workflow.transitions
145146
],
146147
})
147-
initial = self._initial_state
148-
if hasattr(initial, "value"):
149-
initial = initial.value
148+
initial: str = self._initial_state.value if isinstance(self._initial_state, Enum) else self._initial_state
150149

151150
return {
152151
"states": states,

tests/lib/test_agent_card.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from enum import Enum
4-
from typing import Literal
4+
from typing import Literal, override
55
from unittest.mock import AsyncMock, MagicMock, patch
66

77
import pytest
@@ -25,6 +25,7 @@ class WaitingWorkflow(StateWorkflow):
2525
accepts = ["text", "doc_upload"]
2626
transitions = [SampleState.PROCESSING]
2727

28+
@override
2829
async def execute(self, state_machine, state_machine_data=None):
2930
return SampleState.PROCESSING
3031

@@ -34,6 +35,7 @@ class ProcessingWorkflow(StateWorkflow):
3435
accepts = ["text"]
3536
transitions = [SampleState.DONE, SampleState.WAITING]
3637

38+
@override
3739
async def execute(self, state_machine, state_machine_data=None):
3840
return SampleState.DONE
3941

@@ -42,6 +44,7 @@ class DoneWorkflow(StateWorkflow):
4244
description = "Terminal state"
4345
transitions = []
4446

47+
@override
4548
async def execute(self, state_machine, state_machine_data=None):
4649
return SampleState.DONE
4750

@@ -51,6 +54,7 @@ class SampleData(AgentexBaseModel):
5154

5255

5356
class SampleStateMachine(StateMachine[SampleData]):
57+
@override
5458
async def terminal_condition(self):
5559
return self.get_current_state() == SampleState.DONE
5660

0 commit comments

Comments
 (0)