Skip to content

Commit 7d2aa10

Browse files
authored
API docs: improve result stream (#1010)
* Show `__aiter__` and `__anext__` methods' docs string and type annotations. * Mention `StopAsyncIteration` exception raised by `__atier__`. * Same corresponding changes to the sync API.
1 parent 090bf3e commit 7d2aa10

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

docs/source/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,9 @@ A :class:`neo4j.Result` is attached to an active connection, through a :class:`n
13471347

13481348
.. autoclass:: neo4j.Result()
13491349

1350-
.. describe:: iter(result)
1350+
.. automethod:: __iter__
13511351

1352-
.. describe:: next(result)
1352+
.. automethod:: __next__
13531353

13541354
.. automethod:: keys
13551355

docs/source/async_api.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,9 @@ A :class:`neo4j.AsyncResult` is attached to an active connection, through a :cla
865865

866866
.. autoclass:: neo4j.AsyncResult()
867867

868-
.. method:: __aiter__()
869-
:async:
868+
.. automethod:: __aiter__()
870869

871-
.. method:: __anext__()
872-
:async:
870+
.. automethod:: __anext__()
873871

874872
.. automethod:: keys
875873

src/neo4j/_async/work/result.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ async def __aiter__(self) -> t.AsyncIterator[Record]:
286286

287287
@AsyncNonConcurrentMethodChecker.non_concurrent_method
288288
async def __anext__(self) -> Record:
289-
"""Advance the result stream and return the record."""
289+
"""Advance the result stream and return the record.
290+
291+
:raises StopAsyncIteration: if no more records are available.
292+
"""
290293
return await self.__aiter__().__anext__()
291294

292295
async def _attach(self):

src/neo4j/_sync/work/result.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ def __iter__(self) -> t.Iterator[Record]:
286286

287287
@NonConcurrentMethodChecker.non_concurrent_method
288288
def __next__(self) -> Record:
289-
"""Advance the result stream and return the record."""
289+
"""Advance the result stream and return the record.
290+
291+
:raises StopIteration: if no more records are available.
292+
"""
290293
return self.__iter__().__next__()
291294

292295
def _attach(self):

0 commit comments

Comments
 (0)