diff --git a/openbb_sdk/sdk/provider/openbb_provider/utils/helpers.py b/openbb_sdk/sdk/provider/openbb_provider/utils/helpers.py index cba38dd2c25..65e49975298 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/utils/helpers.py +++ b/openbb_sdk/sdk/provider/openbb_provider/utils/helpers.py @@ -5,26 +5,24 @@ import re from typing import Callable, Dict, List, Optional, Type, Union import requests - from openbb_provider.abstract.fetcher import DataType, ProviderDataType def get_querystring(items: dict, exclude: List[str]) -> str: - """Turns a dictionary into a querystring, excluding the keys in the exclude list. + """Turn a dictionary into a querystring, excluding the keys in the exclude list. - Parameters: - ----------- + Parameters + ---------- items: dict The dictionary to be turned into a querystring. exclude: List[str] The keys to be excluded from the querystring. - Returns: - -------- + Returns + ------- str The querystring. - """ for item in exclude: items.pop(item) @@ -35,6 +33,7 @@ def get_querystring(items: dict, exclude: List[str]) -> str: def process( row: ProviderDataType, key: str, processors: Optional[Dict[str, Callable]] = None ): + """Process a specific field.""" if not processors: return getattr(row, key) if key not in processors: @@ -43,7 +42,7 @@ def process( def camel_to_snake(name: str) -> str: - "Converts a camelCase string to snake_case." + """Convert a camelCase string to snake_case.""" pattern = re.compile(r"(? bool: - "Checks if a field has an alias." + """Check if a field has an alias.""" alias = getattr(field, "alias") name = getattr(field, "name") return alias != name @@ -72,10 +72,10 @@ def data_transformer( new_schema: Type[DataType], processors: Optional[Dict[str, Callable]] = None, ) -> Union[List[DataType], DataType]: - """Converts a specific data into the standardised version + """Convert a specific data into the standardised version. - Parameters: - ----------- + Parameters + ---------- data: Union[List[ProviderDataType], ProviderDataType] A list of pydantic schemas @@ -85,11 +85,10 @@ def data_transformer( processors: Optional[Dict[str, str]] A dictionary with fields and custom processing functions - Returns: - -------- + Returns + ------- List[DataType] A list of the newly formatted schemas - """ the_data = data[0] if isinstance(data, list) else data fields = the_data.__dict__.keys()