Skip to content

Commit

Permalink
API docs: improve result stream (#1010)
Browse files Browse the repository at this point in the history
 * Show `__aiter__` and `__anext__` methods' docs string and type annotations.
 * Mention `StopAsyncIteration` exception raised by `__atier__`.
 * Same corresponding changes to the sync API.
  • Loading branch information
robsdedude authored Jan 9, 2024
1 parent 090bf3e commit 7d2aa10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1347,9 +1347,9 @@ A :class:`neo4j.Result` is attached to an active connection, through a :class:`n

.. autoclass:: neo4j.Result()

.. describe:: iter(result)
.. automethod:: __iter__

.. describe:: next(result)
.. automethod:: __next__

.. automethod:: keys

Expand Down
6 changes: 2 additions & 4 deletions docs/source/async_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,9 @@ A :class:`neo4j.AsyncResult` is attached to an active connection, through a :cla

.. autoclass:: neo4j.AsyncResult()

.. method:: __aiter__()
:async:
.. automethod:: __aiter__()

.. method:: __anext__()
:async:
.. automethod:: __anext__()

.. automethod:: keys

Expand Down
5 changes: 4 additions & 1 deletion src/neo4j/_async/work/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ async def __aiter__(self) -> t.AsyncIterator[Record]:

@AsyncNonConcurrentMethodChecker.non_concurrent_method
async def __anext__(self) -> Record:
"""Advance the result stream and return the record."""
"""Advance the result stream and return the record.
:raises StopAsyncIteration: if no more records are available.
"""
return await self.__aiter__().__anext__()

async def _attach(self):
Expand Down
5 changes: 4 additions & 1 deletion src/neo4j/_sync/work/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ def __iter__(self) -> t.Iterator[Record]:

@NonConcurrentMethodChecker.non_concurrent_method
def __next__(self) -> Record:
"""Advance the result stream and return the record."""
"""Advance the result stream and return the record.
:raises StopIteration: if no more records are available.
"""
return self.__iter__().__next__()

def _attach(self):
Expand Down

0 comments on commit 7d2aa10

Please sign in to comment.