|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import json |
| 4 | +from collections.abc import Iterable, Sequence |
4 | 5 | from contextlib import asynccontextmanager |
5 | 6 | from datetime import datetime, timedelta |
6 | | -from typing import Any, Dict, Iterable, Sequence, cast |
| 7 | +from typing import Any, cast |
7 | 8 |
|
8 | 9 | import pytest |
| 10 | +from openai.types.responses.response_output_message_param import ResponseOutputMessageParam |
| 11 | +from openai.types.responses.response_output_text_param import ResponseOutputTextParam |
| 12 | +from openai.types.responses.response_reasoning_item_param import ( |
| 13 | + ResponseReasoningItemParam, |
| 14 | + Summary, |
| 15 | +) |
9 | 16 | from sqlalchemy import select, text, update |
10 | 17 | from sqlalchemy.sql import Select |
11 | 18 |
|
|
15 | 22 | from agents.extensions.memory.sqlalchemy_session import SQLAlchemySession |
16 | 23 | from tests.fake_model import FakeModel |
17 | 24 | from tests.test_responses import get_text_message |
18 | | -from openai.types.responses.response_output_message_param import ResponseOutputMessageParam |
19 | | -from openai.types.responses.response_output_text_param import ResponseOutputTextParam |
20 | | -from openai.types.responses.response_reasoning_item_param import ( |
21 | | - ResponseReasoningItemParam, |
22 | | - Summary, |
23 | | -) |
24 | 25 |
|
25 | 26 | # Mark all tests in this file as asyncio |
26 | 27 | pytestmark = pytest.mark.asyncio |
@@ -58,7 +59,7 @@ def _make_reasoning_item(item_id: str, summary_text: str) -> TResponseInputItem: |
58 | 59 | def _item_ids(items: Sequence[TResponseInputItem]) -> list[str]: |
59 | 60 | result: list[str] = [] |
60 | 61 | for item in items: |
61 | | - item_dict = cast(Dict[str, Any], item) |
| 62 | + item_dict = cast(dict[str, Any], item) |
62 | 63 | result.append(cast(str, item_dict["id"])) |
63 | 64 | return result |
64 | 65 |
|
@@ -332,7 +333,7 @@ async def test_pop_item_same_timestamp_returns_latest(): |
332 | 333 |
|
333 | 334 | popped = await session.pop_item() |
334 | 335 | assert popped is not None |
335 | | - assert cast(Dict[str, Any], popped)["id"] == "msg_pop_same_ts" |
| 336 | + assert cast(dict[str, Any], popped)["id"] == "msg_pop_same_ts" |
336 | 337 |
|
337 | 338 | remaining = await session.get_items() |
338 | 339 | assert _item_ids(remaining) == ["rs_pop_same_ts"] |
|
0 commit comments