Skip to content

Commit 0a3494c

Browse files
refactor(python): add future annotations and remove quoted types
Add `from __future__ import annotations` to 93 package files that used quoted string annotations, then run pyupgrade --py310-plus to remove the now-unnecessary quotes. Fixes #3578
1 parent 8f7a5e0 commit 0a3494c

85 files changed

Lines changed: 350 additions & 191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

python/packages/a2a/agent_framework_a2a/_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Copyright (c) Microsoft. All rights reserved.
22

3+
from __future__ import annotations
4+
35
import base64
46
import json
57
import re
@@ -169,7 +171,7 @@ def _create_timeout_config(self, timeout: float | httpx.Timeout | None) -> httpx
169171
msg = f"Invalid timeout type: {type(timeout)}. Expected float, httpx.Timeout, or None."
170172
raise TypeError(msg)
171173

172-
async def __aenter__(self) -> "A2AAgent":
174+
async def __aenter__(self) -> A2AAgent:
173175
"""Async context manager entry."""
174176
return self
175177

python/packages/ag-ui/agent_framework_ag_ui/_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""AG-UI Chat Client implementation."""
44

5+
from __future__ import annotations
6+
57
import json
68
import logging
79
import sys
@@ -216,7 +218,7 @@ def __init__(
216218
http_client: httpx.AsyncClient | None = None,
217219
timeout: float = 60.0,
218220
additional_properties: dict[str, Any] | None = None,
219-
middleware: Sequence["ChatAndFunctionMiddlewareTypes"] | None = None,
221+
middleware: Sequence[ChatAndFunctionMiddlewareTypes] | None = None,
220222
function_invocation_configuration: FunctionInvocationConfiguration | None = None,
221223
**kwargs: Any,
222224
) -> None:

python/packages/ag-ui/agent_framework_ag_ui/_endpoint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""FastAPI endpoint creation for AG-UI agents."""
44

5+
from __future__ import annotations
6+
57
import copy
68
import logging
79
from collections.abc import AsyncGenerator, Sequence
@@ -77,7 +79,7 @@ async def agent_endpoint(request_body: AGUIRequest) -> StreamingResponse | dict[
7779
)
7880
logger.info(f"Received request at {path}: {input_data.get('run_id', 'no-run-id')}")
7981

80-
async def event_generator() -> AsyncGenerator[str, None]:
82+
async def event_generator() -> AsyncGenerator[str]:
8183
encoder = EventEncoder()
8284
event_count = 0
8385
async for event in wrapped_agent.run_agent(input_data):

python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Event converter for AG-UI protocol events to Agent Framework types."""
44

5+
from __future__ import annotations
6+
57
from typing import Any
68

79
from agent_framework import (

python/packages/ag-ui/agent_framework_ag_ui/_http_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""HTTP service for AG-UI protocol communication."""
44

5+
from __future__ import annotations
6+
57
import json
68
import logging
79
from collections.abc import AsyncIterable
@@ -148,7 +150,7 @@ async def close(self) -> None:
148150
if self._owns_client and self.http_client:
149151
await self.http_client.aclose()
150152

151-
async def __aenter__(self) -> "AGUIHttpService":
153+
async def __aenter__(self) -> AGUIHttpService:
152154
"""Enter async context manager."""
153155
return self
154156

python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Message format conversion between AG-UI and Agent Framework."""
44

5+
from __future__ import annotations
6+
57
import json
68
import logging
79
from typing import Any, cast

python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
This module retains utilities that may be useful for testing or extensions.
77
"""
88

9+
from __future__ import annotations
10+
911
import json
1012
import logging
1113
from typing import Any

python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_predictive_state.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Predictive state handling utilities."""
44

5+
from __future__ import annotations
6+
57
import json
68
import logging
79
import re

python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_tooling.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Tool handling helpers."""
44

5+
from __future__ import annotations
6+
57
import logging
68
from typing import TYPE_CHECKING, Any
79

@@ -29,7 +31,7 @@ def _collect_mcp_tool_functions(mcp_tools: list[Any]) -> list[Any]:
2931
return functions
3032

3133

32-
def collect_server_tools(agent: "SupportsAgentRun") -> list[Any]:
34+
def collect_server_tools(agent: SupportsAgentRun) -> list[Any]:
3335
"""Collect server tools from an agent.
3436
3537
This includes both regular tools from default_options and MCP tools.
@@ -64,7 +66,7 @@ def collect_server_tools(agent: "SupportsAgentRun") -> list[Any]:
6466
return server_tools
6567

6668

67-
def register_additional_client_tools(agent: "SupportsAgentRun", client_tools: list[Any] | None) -> None:
69+
def register_additional_client_tools(agent: SupportsAgentRun, client_tools: list[Any] | None) -> None:
6870
"""Register client tools as additional declaration-only tools to avoid server execution.
6971
7072
Args:

python/packages/ag-ui/agent_framework_ag_ui/_run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Simplified AG-UI orchestration - single linear flow."""
44

5+
from __future__ import annotations
6+
57
import json
68
import logging
79
import uuid
@@ -742,8 +744,8 @@ def _build_messages_snapshot(
742744
async def run_agent_stream(
743745
input_data: dict[str, Any],
744746
agent: SupportsAgentRun,
745-
config: "AgentConfig",
746-
) -> "AsyncGenerator[BaseEvent, None]":
747+
config: AgentConfig,
748+
) -> AsyncGenerator[BaseEvent]:
747749
"""Run agent and yield AG-UI events.
748750
749751
This is the single entry point for all AG-UI agent runs. It follows a simple

0 commit comments

Comments
 (0)