Skip to content

Commit 792b9bb

Browse files
plutolessclaude
andcommitted
fix(ci): bump minimum Python to 3.9 and fix type errors from #37
PR #37 broke all three CI jobs: - test / compat-build: cn.py uses PEP 585 builtins (`list[str]`) which fail at Pydantic model-build time on Python 3.8. Raise the minimum supported version to 3.9 (pyproject + compat pyproject + CI matrix, poetry.lock refreshed) so the existing annotations are valid. - compile (mypy): fix the type errors introduced alongside the new regional/CN feature: * Remove the `@overload` stubs on Agent/Agora `__new__`/`__init__` (they could not be paired with their implementations by mypy). Runtime dispatch is unchanged; only static return-type precision is dropped. * __init__.py: import AgentClient/AsyncAgentClient from .pool_client (where they are defined) instead of .agentkit. * Agent.turn_detection / _resolve_asr_config: accept dict as well as the model, matching runtime behaviour. * regional_agent.py: type: ignore[override] for the intentional regional-vendor parameter narrowing. * test_regional_vendors.py: narrow Optional before indexing. Verified: mypy clean (303 files), 193 passed / 1 skipped, lock consistent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2865172 commit 792b9bb

9 files changed

Lines changed: 30 additions & 286 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- name: Set up python
1010
uses: actions/setup-python@v4
1111
with:
12-
python-version: 3.8
12+
python-version: 3.9
1313
- name: Bootstrap poetry
1414
run: |
1515
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up python
2828
uses: actions/setup-python@v4
2929
with:
30-
python-version: 3.8
30+
python-version: 3.9
3131
- name: Bootstrap poetry
3232
run: |
3333
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up python
4646
uses: actions/setup-python@v4
4747
with:
48-
python-version: 3.8
48+
python-version: 3.9
4949
- name: Bootstrap poetry
5050
run: |
5151
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
@@ -77,7 +77,7 @@ jobs:
7777
- name: Set up python
7878
uses: actions/setup-python@v4
7979
with:
80-
python-version: 3.8
80+
python-version: 3.9
8181
- name: Bootstrap poetry
8282
run: |
8383
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1

compat/agora-agent-server-sdk/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ classifiers = [
1313
"Intended Audience :: Developers",
1414
"Programming Language :: Python",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.8",
1716
"Programming Language :: Python :: 3.9",
1817
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
@@ -34,7 +33,7 @@ packages = [
3433
Repository = 'https://github.com/AgoraIO-Conversational-AI/agent-server-sdk-python'
3534

3635
[tool.poetry.dependencies]
37-
python = "^3.8"
36+
python = "^3.9"
3837
agora-agents = ">=2.2.0,<3.0.0"
3938

4039
[build-system]

poetry.lock

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

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ classifiers = [
1313
"Intended Audience :: Developers",
1414
"Programming Language :: Python",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.8",
1716
"Programming Language :: Python :: 3.9",
1817
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
@@ -34,7 +33,7 @@ packages = [
3433
Repository = 'https://github.com/AgoraIO-Conversational-AI/agent-server-sdk-python'
3534

3635
[tool.poetry.dependencies]
37-
python = "^3.8"
36+
python = "^3.9"
3837
httpx = ">=0.21.2"
3938
pydantic = ">= 1.9.2"
4039
pydantic-core = ">=2.18.2"

src/agora_agent/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
if typing.TYPE_CHECKING:
1313
from . import agents, agentkit, core, phone_numbers, telephony
1414
from .core.domain import Area, Pool, create_pool
15-
from .pool_client import Agora, AsyncAgora
15+
from .pool_client import Agora, AsyncAgora, AgentClient, AsyncAgentClient
1616
from .version import __version__
1717
from .agentkit import (
1818
Agent,
1919
AgentSession,
2020
AgentSessionOptions,
21-
AgentClient,
22-
AsyncAgentClient,
2321
CNAgent,
2422
GlobalAgent,
2523
GenericAvatar,

src/agora_agent/agentkit/agent.py

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -350,54 +350,6 @@ class Agent:
350350
... )
351351
"""
352352

353-
if typing.TYPE_CHECKING:
354-
_GlobalArea = typing_extensions.Literal[Area.US, Area.EU, Area.AP]
355-
356-
@typing.overload
357-
def __new__(
358-
cls,
359-
client: "Agora[typing_extensions.Literal[Area.CN]]",
360-
*args: typing.Any,
361-
**kwargs: typing.Any,
362-
) -> "CNAgent":
363-
...
364-
365-
@typing.overload
366-
def __new__(
367-
cls,
368-
client: "Agora[_GlobalArea]",
369-
*args: typing.Any,
370-
**kwargs: typing.Any,
371-
) -> "GlobalAgent":
372-
...
373-
374-
@typing.overload
375-
def __new__(
376-
cls,
377-
client: "AsyncAgora[typing_extensions.Literal[Area.CN]]",
378-
*args: typing.Any,
379-
**kwargs: typing.Any,
380-
) -> "CNAgent":
381-
...
382-
383-
@typing.overload
384-
def __new__(
385-
cls,
386-
client: "AsyncAgora[_GlobalArea]",
387-
*args: typing.Any,
388-
**kwargs: typing.Any,
389-
) -> "GlobalAgent":
390-
...
391-
392-
@typing.overload
393-
def __new__(
394-
cls,
395-
client: typing.Any,
396-
*args: typing.Any,
397-
**kwargs: typing.Any,
398-
) -> "Agent":
399-
...
400-
401353
def __new__(
402354
cls,
403355
client: typing.Any = None,
@@ -422,7 +374,7 @@ def __init__(
422374
self,
423375
client: typing.Any,
424376
instructions: typing.Optional[str] = None,
425-
turn_detection: typing.Optional[TurnDetectionConfig] = None,
377+
turn_detection: typing.Optional[typing.Union[TurnDetectionConfig, typing.Dict[str, typing.Any]]] = None,
426378
interruption: typing.Optional[InterruptionConfig] = None,
427379
sal: typing.Optional[SalConfig] = None,
428380
advanced_features: typing.Optional[AdvancedFeatures] = None,
@@ -733,7 +685,7 @@ def mllm(self) -> typing.Optional[typing.Dict[str, typing.Any]]:
733685
return self._mllm
734686

735687
@property
736-
def turn_detection(self) -> typing.Optional[TurnDetectionConfig]:
688+
def turn_detection(self) -> typing.Optional[typing.Union[TurnDetectionConfig, typing.Dict[str, typing.Any]]]:
737689
return self._turn_detection
738690

739691
@property
@@ -1072,7 +1024,10 @@ def _resolve_llm_config(self) -> typing.Dict[str, typing.Any]:
10721024
llm_config["max_history"] = self._max_history
10731025
return llm_config
10741026

1075-
def _resolve_asr_config(self, turn_detection_config: TurnDetectionConfig) -> typing.Dict[str, typing.Any]:
1027+
def _resolve_asr_config(
1028+
self,
1029+
turn_detection_config: typing.Union[TurnDetectionConfig, typing.Dict[str, typing.Any]],
1030+
) -> typing.Dict[str, typing.Any]:
10761031
asr_config = dict(self._stt or {})
10771032
if not asr_config:
10781033
asr_config["vendor"] = "ares"

src/agora_agent/agentkit/regional_agent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,30 +108,30 @@
108108

109109

110110
class CNAgent(Agent):
111-
def with_stt(self, vendor: CNSTT) -> "CNAgent":
111+
def with_stt(self, vendor: CNSTT) -> "CNAgent": # type: ignore[override]
112112
return typing.cast("CNAgent", super().with_stt(typing.cast(BaseSTT, vendor)))
113113

114-
def with_llm(self, vendor: CNLLM) -> "CNAgent":
114+
def with_llm(self, vendor: CNLLM) -> "CNAgent": # type: ignore[override]
115115
return typing.cast("CNAgent", super().with_llm(typing.cast(BaseLLM, vendor)))
116116

117-
def with_tts(self, vendor: CNTTS) -> "CNAgent":
117+
def with_tts(self, vendor: CNTTS) -> "CNAgent": # type: ignore[override]
118118
return typing.cast("CNAgent", super().with_tts(typing.cast(BaseTTS, vendor)))
119119

120-
def with_avatar(self, vendor: CNAvatar) -> "CNAgent":
120+
def with_avatar(self, vendor: CNAvatar) -> "CNAgent": # type: ignore[override]
121121
return typing.cast("CNAgent", super().with_avatar(typing.cast(BaseAvatar, vendor)))
122122

123123

124124
class GlobalAgent(Agent):
125-
def with_stt(self, vendor: GlobalSTT) -> "GlobalAgent":
125+
def with_stt(self, vendor: GlobalSTT) -> "GlobalAgent": # type: ignore[override]
126126
return typing.cast("GlobalAgent", super().with_stt(typing.cast(BaseSTT, vendor)))
127127

128-
def with_llm(self, vendor: GlobalLLM) -> "GlobalAgent":
128+
def with_llm(self, vendor: GlobalLLM) -> "GlobalAgent": # type: ignore[override]
129129
return typing.cast("GlobalAgent", super().with_llm(typing.cast(BaseLLM, vendor)))
130130

131-
def with_tts(self, vendor: GlobalTTS) -> "GlobalAgent":
131+
def with_tts(self, vendor: GlobalTTS) -> "GlobalAgent": # type: ignore[override]
132132
return typing.cast("GlobalAgent", super().with_tts(typing.cast(BaseTTS, vendor)))
133133

134-
def with_avatar(self, vendor: GlobalAvatar) -> "GlobalAgent":
134+
def with_avatar(self, vendor: GlobalAvatar) -> "GlobalAgent": # type: ignore[override]
135135
return typing.cast("GlobalAgent", super().with_avatar(typing.cast(BaseAvatar, vendor)))
136136

137137

0 commit comments

Comments
 (0)