refactor: update module docstrings for clarity and consistency
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
"""Typed wrapper around fastapi-pagination for backend query helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable, Sequence
|
||||
from typing import Any, TypeVar, cast
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
||||
|
||||
from fastapi_pagination.ext.sqlalchemy import paginate as _paginate
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
from sqlmodel.sql.expression import Select, SelectOfScalar
|
||||
|
||||
from app.schemas.pagination import DefaultLimitOffsetPage
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
from sqlmodel.sql.expression import Select, SelectOfScalar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
Transformer = Callable[[Sequence[Any]], Sequence[Any] | Awaitable[Sequence[Any]]]
|
||||
@@ -20,8 +24,10 @@ async def paginate(
|
||||
*,
|
||||
transformer: Transformer | None = None,
|
||||
) -> DefaultLimitOffsetPage[T]:
|
||||
# fastapi-pagination is not fully typed (it returns Any), but response_model validation
|
||||
# ensures runtime correctness. Centralize casts here to keep strict mypy clean.
|
||||
"""Execute a paginated query and cast to the project page type alias."""
|
||||
# fastapi-pagination is not fully typed (it returns Any), but response_model
|
||||
# validation ensures runtime correctness. Centralize casts here to keep strict
|
||||
# mypy clean.
|
||||
return cast(
|
||||
DefaultLimitOffsetPage[T],
|
||||
await _paginate(session, statement, transformer=transformer),
|
||||
|
||||
Reference in New Issue
Block a user