Skip to content

Commit f16ba40

Browse files
author
matmoncon
committed
docs: add comments to remaining client methods
1 parent d1b6872 commit f16ba40

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pyneo4j_ogm/core/client.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -672,25 +672,22 @@ async def _commit_transaction(self) -> None:
672672
Commits the currently active transaction and closes it.
673673
"""
674674
logger.debug("Committing transaction %s", self._transaction)
675-
try:
676-
await cast(AsyncTransaction, self._transaction).commit() # type: ignore
677-
bookmarks = await cast(AsyncSession, self._session).last_bookmarks()
678-
self.last_bookmarks = set(bookmarks.raw_values)
679-
finally:
680-
self._session = None
681-
self._transaction = None
675+
await cast(AsyncTransaction, self._transaction).commit() # type: ignore
676+
bookmarks = await cast(AsyncSession, self._session).last_bookmarks()
677+
self.last_bookmarks = set(bookmarks.raw_values)
678+
679+
self._session = None
680+
self._transaction = None
682681

683682
@ensure_connection
684683
async def _rollback_transaction(self) -> None:
685684
"""
686685
Rolls back the currently active transaction and closes it.
687686
"""
688687
logger.debug("Rolling back transaction %s", self._transaction)
689-
try:
690-
await cast(AsyncTransaction, self._transaction).rollback() # type: ignore
691-
finally:
692-
self._session = None
693-
self._transaction = None
688+
await cast(AsyncTransaction, self._transaction).rollback() # type: ignore
689+
self._session = None
690+
self._transaction = None
694691

695692
def _resolve_database_model(self, query_result: Any) -> Optional[Any]:
696693
"""
@@ -704,6 +701,7 @@ def _resolve_database_model(self, query_result: Any) -> Optional[Any]:
704701
with `Path.nodes` and `Path.relationships` resolved to the database models.
705702
"""
706703
if isinstance(query_result, Path):
704+
# If the result is a path, resolve the nodes and relationships inside the path
707705
logger.debug("Query result %s is a path, resolving nodes and relationship", query_result)
708706
nodes = []
709707
relationships = []
@@ -723,6 +721,7 @@ def _resolve_database_model(self, query_result: Any) -> Optional[Any]:
723721

724722
return query_result
725723
elif isinstance(query_result, (Node, Relationship)):
724+
# Get type or labels and try to resolve the query result to a registered model
726725
logger.debug("Query result %s is a node or relationship, resolving", query_result)
727726
labels = set(query_result.labels) if isinstance(query_result, Node) else {query_result.type}
728727

0 commit comments

Comments
 (0)