Skip to content

Commit

Permalink
📝 docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-andre committed May 26, 2024
1 parent 1ab0d1e commit f38739a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
13 changes: 13 additions & 0 deletions pyodmongo/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@


class DbResponse(BaseModel):
"""
A class representing the response from database operations.
Attributes:
acknowledged (bool): Whether the operation was acknowledged by the server.
deleted_count (int): The number of documents deleted.
inserted_count (int): The number of documents inserted.
matched_count (int): The number of documents matched by the query.
modified_count (int): The number of documents modified.
upserted_count (int): The number of documents upserted (inserted or replaced).
upserted_ids (dict[int, Id]): A dictionary mapping index to the upserted document IDs.
"""

acknowledged: bool
deleted_count: int
inserted_count: int
Expand Down
23 changes: 21 additions & 2 deletions pyodmongo/services/verify_subclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@
from types import NoneType


def _rec_verify(class_list: list):
def _rec_verify(class_list: list) -> list:
"""
Recursively verify the class hierarchy and extend the class list with base classes.
Args:
class_list (list): A list of classes to be verified.
Returns:
list: The extended list of classes including all base classes.
"""
for cls in class_list:
class_list += list(cls.__bases__)
return class_list


def is_subclass(class_to_verify: Any, subclass: Any):
def is_subclass(class_to_verify: Any, subclass: Any) -> bool:
"""
Check if the class_to_verify is a subclass of the given subclass.
Args:
class_to_verify (Any): The class to be verified.
subclass (Any): The subclass to check against.
Returns:
bool: True if class_to_verify is a subclass of subclass, otherwise False.
"""
if class_to_verify is NoneType:
return True
if (
Expand Down

0 comments on commit f38739a

Please sign in to comment.