Skip to content

docs: add some missing inline documentation #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ def __init__(


class BasePage(GenericModel, Generic[ModelT]):
"""
Defines the core interface for pagination.

Type Args:
ModelT: The pydantic model that represents an item in the response.

Methods:
has_next_page(): Check if there is another page available
next_page_info(): Get the necesary information to make a request for the next page
"""

_options: FinalRequestOptions = PrivateAttr()
_model: Type[ModelT] = PrivateAttr()

Expand Down
4 changes: 4 additions & 0 deletions src/finch/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def _get_annoted_type(type_: type) -> type | None:


def _maybe_transform_key(key: str, type_: type) -> str:
"""Transform the given `data` based on the annotations provided in `type_`.

Note: this function only looks at `Annotated` types that contain `PropertInfo` metadata.
"""
annotated_type = _get_annoted_type(type_)
if annotated_type is None:
# no `Annotated` definition for this type, no transformation needed
Expand Down
6 changes: 6 additions & 0 deletions src/finch/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def extract_files(
*,
paths: Sequence[Sequence[str]],
) -> list[tuple[str, FileTypes]]:
"""Recursively extract files from the given dictionary based on specified paths.

A path may look like this ['foo', 'files', '<array>', 'data'].

Note: this mutates the given dictionary.
"""
files: list[tuple[str, FileTypes]] = []
for path in paths:
files.extend(_extract_items(query, path, index=0, flattened_key=None))
Expand Down