|
8 | 8 | from collections.abc import AsyncIterator |
9 | 9 | from contextvars import ContextVar |
10 | 10 | from datetime import datetime |
11 | | -from typing import Any, Self, cast |
| 11 | +from typing import Any, Self, cast, TYPE_CHECKING |
12 | 12 |
|
13 | 13 | from pydantic import TypeAdapter |
14 | 14 | from sqlalchemy import DateTime, MetaData, func, select |
15 | 15 | from sqlalchemy.exc import OperationalError |
16 | 16 | from sqlalchemy.ext.asyncio import AsyncConnection, AsyncEngine, create_async_engine |
17 | 17 |
|
| 18 | +if TYPE_CHECKING: |
| 19 | + from sqlalchemy.orm import DeclarativeBase |
| 20 | + |
18 | 21 | from diracx.core.exceptions import InvalidQueryError |
19 | 22 | from diracx.core.extensions import select_from_extension |
20 | 23 | from diracx.core.models import ( |
@@ -233,7 +236,7 @@ async def ping(self): |
233 | 236 |
|
234 | 237 | async def _search( |
235 | 238 | self, |
236 | | - table: Any, |
| 239 | + table: type[DeclarativeBase], |
237 | 240 | parameters: list[str] | None, |
238 | 241 | search: list[SearchSpec], |
239 | 242 | sorts: list[SortSpec], |
@@ -273,7 +276,7 @@ async def _search( |
273 | 276 | ] |
274 | 277 |
|
275 | 278 | async def _summary( |
276 | | - self, table: Any, group_by: list[str], search: list[SearchSpec] |
| 279 | + self, table: type[DeclarativeBase], group_by: list[str], search: list[SearchSpec] |
277 | 280 | ) -> list[dict[str, str | int]]: |
278 | 281 | """Get a summary of the elements of a table.""" |
279 | 282 | columns = _get_columns(table.__table__, group_by) |
|
0 commit comments