summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/asyncio
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-04-11 10:54:42 -0400
committermike bayer <mike_mp@zzzcomputing.com>2022-04-12 02:09:36 +0000
commit15ef11e0ede82e44fb07f31b63d3db0712d8bf48 (patch)
tree7c46d8a388f88b5e5265c20e126f9ae60e97b700 /lib/sqlalchemy/ext/asyncio
parent8254e3a28a32b7097fb926a373c17c35d4ec1d57 (diff)
downloadsqlalchemy-15ef11e0ede82e44fb07f31b63d3db0712d8bf48.tar.gz
level up pep-484 on engine result
Have each result subclass be generic to the kind of row/object it returns. rework things so that a significant number of "type ignores" can go away and also allow asyncio to more cleanly proxy the result objects. Change-Id: Ia3ddb2cb52f5856839bd8c9c46f0289ab4b10405
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio')
-rw-r--r--lib/sqlalchemy/ext/asyncio/result.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/result.py b/lib/sqlalchemy/ext/asyncio/result.py
index 62e4a9a0e..39718735c 100644
--- a/lib/sqlalchemy/ext/asyncio/result.py
+++ b/lib/sqlalchemy/ext/asyncio/result.py
@@ -131,7 +131,7 @@ class AsyncResult(AsyncCommon):
if row is _NO_ROW:
return None
else:
- return row
+ return row # type: ignore[return-value]
async def fetchmany(self, size=None):
"""Fetch many rows.
@@ -152,7 +152,9 @@ class AsyncResult(AsyncCommon):
"""
- return await greenlet_spawn(self._manyrow_getter, self, size)
+ return await greenlet_spawn(
+ self._manyrow_getter, self, size # type: ignore
+ )
async def all(self):
"""Return all rows in a list.
@@ -164,7 +166,7 @@ class AsyncResult(AsyncCommon):
"""
- return await greenlet_spawn(self._allrows)
+ return await greenlet_spawn(self._allrows) # type: ignore
def __aiter__(self):
return self
@@ -551,8 +553,8 @@ class AsyncMappingResult(AsyncCommon):
"""Iterate through sub-lists of elements of the size given.
Equivalent to :meth:`_asyncio.AsyncResult.partitions` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
@@ -574,8 +576,8 @@ class AsyncMappingResult(AsyncCommon):
"""Fetch one object.
Equivalent to :meth:`_asyncio.AsyncResult.fetchone` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
@@ -589,8 +591,8 @@ class AsyncMappingResult(AsyncCommon):
"""Fetch many objects.
Equivalent to :meth:`_asyncio.AsyncResult.fetchmany` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
@@ -600,8 +602,8 @@ class AsyncMappingResult(AsyncCommon):
"""Return all scalar values in a list.
Equivalent to :meth:`_asyncio.AsyncResult.all` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
@@ -621,8 +623,8 @@ class AsyncMappingResult(AsyncCommon):
"""Fetch the first object or None if no object is present.
Equivalent to :meth:`_asyncio.AsyncResult.first` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
@@ -632,8 +634,8 @@ class AsyncMappingResult(AsyncCommon):
"""Return at most one object or raise an exception.
Equivalent to :meth:`_asyncio.AsyncResult.one_or_none` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
return await greenlet_spawn(self._only_one_row, True, False, False)
@@ -642,8 +644,8 @@ class AsyncMappingResult(AsyncCommon):
"""Return exactly one object or raise an exception.
Equivalent to :meth:`_asyncio.AsyncResult.one` except that
- mapping values, rather than :class:`_result.Row` objects,
- are returned.
+ :class:`_result.RowMapping` values, rather than :class:`_result.Row`
+ objects, are returned.
"""
return await greenlet_spawn(self._only_one_row, True, True, False)