From 56fd9c818ff0e4caaea6e26d4b84df09e004340f Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Tue, 29 Oct 2024 12:25:46 +0100 Subject: [PATCH] fix a few wrong type annotations --- src/bfabric/bfabric_config.py | 2 +- src/bfabric/results/response_format_dict.py | 4 ++-- src/bfabric/utils/paginator.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bfabric/bfabric_config.py b/src/bfabric/bfabric_config.py index 0ccf2933..cf4ca7e9 100644 --- a/src/bfabric/bfabric_config.py +++ b/src/bfabric/bfabric_config.py @@ -12,7 +12,7 @@ def read_config( config_path: str | Path, - config_env: str = None, + config_env: str | None = None, ) -> tuple[BfabricClientConfig, BfabricAuth | None]: """ Reads bfabricpy.yml file, parses it, extracting authentication and configuration data diff --git a/src/bfabric/results/response_format_dict.py b/src/bfabric/results/response_format_dict.py index fb7e0cc5..e05bb5e9 100644 --- a/src/bfabric/results/response_format_dict.py +++ b/src/bfabric/results/response_format_dict.py @@ -33,14 +33,14 @@ def _recursive_drop_empty(response_elem: list | dict) -> None: del response_elem[k] -def drop_empty_elements(response: list | dict, inplace: bool = True) -> list | dict | None: +def drop_empty_elements(response: list | dict, inplace: bool = True) -> list | dict: """ Iterates over all nested lists, dictionaries and basic values. Whenever a dictionary value is encountered, that is either an empty list or None, the key-value pair gets deleted from the dictionary :param response: A parsed query response, consisting of nested lists, dicts and basic types (int, str) :param inplace: If true, will return nothing and edit the argument. Otherwise, will preserve the argument and return an edited copy - :return: Nothing, or an edited response, depending on `inplace` + :return: An edited response, depending on `inplace` """ response_filtered = deepcopy(response) if not inplace else response _recursive_drop_empty(response_filtered) diff --git a/src/bfabric/utils/paginator.py b/src/bfabric/utils/paginator.py index f20312b3..5bdddb20 100644 --- a/src/bfabric/utils/paginator.py +++ b/src/bfabric/utils/paginator.py @@ -1,12 +1,13 @@ from __future__ import annotations import math +from collections.abc import Generator # Single page query limit for BFabric API (as of time of writing, adapt if it changes) BFABRIC_QUERY_LIMIT = 100 -def page_iter(objs: list, page_size: int = BFABRIC_QUERY_LIMIT) -> list: +def page_iter(objs: list, page_size: int = BFABRIC_QUERY_LIMIT) -> Generator[list, None, None]: """ :param objs: A list of objects to provide to bfabric as part of a query :param page_size: Number of objects per page