API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -1,5 +1,5 @@
# ext/asyncio/result.py
# Copyright (C) 2020-2023 the SQLAlchemy authors and contributors
# Copyright (C) 2020-2025 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -93,6 +93,7 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
self._metadata = real_result._metadata
self._unique_filter_state = real_result._unique_filter_state
self._source_supports_scalars = real_result._source_supports_scalars
self._post_creational_filter = None
# BaseCursorResult pre-generates the "_row_getter". Use that
@@ -324,22 +325,20 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
return await greenlet_spawn(self._only_one_row, True, False, False)
@overload
async def scalar_one(self: AsyncResult[Tuple[_T]]) -> _T:
...
async def scalar_one(self: AsyncResult[Tuple[_T]]) -> _T: ...
@overload
async def scalar_one(self) -> Any:
...
async def scalar_one(self) -> Any: ...
async def scalar_one(self) -> Any:
"""Return exactly one scalar result or raise an exception.
This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
then :meth:`_asyncio.AsyncResult.one`.
then :meth:`_asyncio.AsyncScalarResult.one`.
.. seealso::
:meth:`_asyncio.AsyncResult.one`
:meth:`_asyncio.AsyncScalarResult.one`
:meth:`_asyncio.AsyncResult.scalars`
@@ -349,22 +348,20 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
@overload
async def scalar_one_or_none(
self: AsyncResult[Tuple[_T]],
) -> Optional[_T]:
...
) -> Optional[_T]: ...
@overload
async def scalar_one_or_none(self) -> Optional[Any]:
...
async def scalar_one_or_none(self) -> Optional[Any]: ...
async def scalar_one_or_none(self) -> Optional[Any]:
"""Return exactly one scalar result or ``None``.
This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
then :meth:`_asyncio.AsyncResult.one_or_none`.
then :meth:`_asyncio.AsyncScalarResult.one_or_none`.
.. seealso::
:meth:`_asyncio.AsyncResult.one_or_none`
:meth:`_asyncio.AsyncScalarResult.one_or_none`
:meth:`_asyncio.AsyncResult.scalars`
@@ -403,12 +400,10 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
return await greenlet_spawn(self._only_one_row, True, True, False)
@overload
async def scalar(self: AsyncResult[Tuple[_T]]) -> Optional[_T]:
...
async def scalar(self: AsyncResult[Tuple[_T]]) -> Optional[_T]: ...
@overload
async def scalar(self) -> Any:
...
async def scalar(self) -> Any: ...
async def scalar(self) -> Any:
"""Fetch the first column of the first row, and close the result set.
@@ -452,16 +447,13 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
@overload
def scalars(
self: AsyncResult[Tuple[_T]], index: Literal[0]
) -> AsyncScalarResult[_T]:
...
) -> AsyncScalarResult[_T]: ...
@overload
def scalars(self: AsyncResult[Tuple[_T]]) -> AsyncScalarResult[_T]:
...
def scalars(self: AsyncResult[Tuple[_T]]) -> AsyncScalarResult[_T]: ...
@overload
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]:
...
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]: ...
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]:
"""Return an :class:`_asyncio.AsyncScalarResult` filtering object which
@@ -833,11 +825,9 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
"""
...
async def __aiter__(self) -> AsyncIterator[_R]:
...
def __aiter__(self) -> AsyncIterator[_R]: ...
async def __anext__(self) -> _R:
...
async def __anext__(self) -> _R: ...
async def first(self) -> Optional[_R]:
"""Fetch the first object or ``None`` if no object is present.
@@ -871,22 +861,20 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
...
@overload
async def scalar_one(self: AsyncTupleResult[Tuple[_T]]) -> _T:
...
async def scalar_one(self: AsyncTupleResult[Tuple[_T]]) -> _T: ...
@overload
async def scalar_one(self) -> Any:
...
async def scalar_one(self) -> Any: ...
async def scalar_one(self) -> Any:
"""Return exactly one scalar result or raise an exception.
This is equivalent to calling :meth:`_engine.Result.scalars`
and then :meth:`_engine.Result.one`.
and then :meth:`_engine.AsyncScalarResult.one`.
.. seealso::
:meth:`_engine.Result.one`
:meth:`_engine.AsyncScalarResult.one`
:meth:`_engine.Result.scalars`
@@ -896,22 +884,20 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
@overload
async def scalar_one_or_none(
self: AsyncTupleResult[Tuple[_T]],
) -> Optional[_T]:
...
) -> Optional[_T]: ...
@overload
async def scalar_one_or_none(self) -> Optional[Any]:
...
async def scalar_one_or_none(self) -> Optional[Any]: ...
async def scalar_one_or_none(self) -> Optional[Any]:
"""Return exactly one or no scalar result.
This is equivalent to calling :meth:`_engine.Result.scalars`
and then :meth:`_engine.Result.one_or_none`.
and then :meth:`_engine.AsyncScalarResult.one_or_none`.
.. seealso::
:meth:`_engine.Result.one_or_none`
:meth:`_engine.AsyncScalarResult.one_or_none`
:meth:`_engine.Result.scalars`
@@ -919,12 +905,12 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
...
@overload
async def scalar(self: AsyncTupleResult[Tuple[_T]]) -> Optional[_T]:
...
async def scalar(
self: AsyncTupleResult[Tuple[_T]],
) -> Optional[_T]: ...
@overload
async def scalar(self) -> Any:
...
async def scalar(self) -> Any: ...
async def scalar(self) -> Any:
"""Fetch the first column of the first row, and close the result