diff --git a/openbb_platform/core/openbb_core/provider/standard_models/key_executives.py b/openbb_platform/core/openbb_core/provider/standard_models/key_executives.py index 143e4973407..c33e7c583c6 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/key_executives.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/key_executives.py @@ -1,6 +1,6 @@ """Key Executives Standard Model.""" -from typing import List, Optional, Set, Union +from typing import Optional from pydantic import Field, field_validator @@ -16,11 +16,9 @@ class KeyExecutivesQueryParams(QueryParams): @field_validator("symbol", mode="before", check_fields=False) @classmethod - def upper_symbol(cls, v: Union[str, List[str], Set[str]]): + def upper_symbol(cls, v: str) -> str: """Convert symbol to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) + return v.upper() class KeyExecutivesData(Data): diff --git a/openbb_platform/core/openbb_core/provider/utils/validators.py b/openbb_platform/core/openbb_core/provider/utils/validators.py index 11bcaa616d2..70865cbf2ef 100644 --- a/openbb_platform/core/openbb_core/provider/utils/validators.py +++ b/openbb_platform/core/openbb_core/provider/utils/validators.py @@ -5,8 +5,7 @@ from typing import Optional def check_single(field: str, value: Optional[str]) -> Optional[str]: """Check that string is a single value.""" - if value: - if "," in value or ";" in value: + if value and ("," in value or ";" in value): raise ValueError(f"multiple values not allowed for field '{field}'") return value diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/key_executives.py b/openbb_platform/providers/fmp/openbb_fmp/models/key_executives.py index 2329c7a7603..e32e9df7936 100644 --- a/openbb_platform/providers/fmp/openbb_fmp/models/key_executives.py +++ b/openbb_platform/providers/fmp/openbb_fmp/models/key_executives.py @@ -18,6 +18,8 @@ class FMPKeyExecutivesQueryParams(KeyExecutivesQueryParams): Source: https://financialmodelingprep.com/developer/docs/#Key-Executives """ + __validator_dict__ = {"check_single": ("symbol",)} + class FMPKeyExecutivesData(KeyExecutivesData): """FMP Key Executives Data.""" diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/historical_dividends.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/historical_dividends.py index 52c84ba58eb..57e866dd784 100644 --- a/openbb_platform/providers/yfinance/openbb_yfinance/models/historical_dividends.py +++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/historical_dividends.py @@ -1,7 +1,6 @@ """YFinance Historical Dividends Model.""" # pylint: disable=unused-argument -import warnings from typing import Any, Dict, List, Optional from openbb_core.provider.abstract.fetcher import Fetcher @@ -11,8 +10,6 @@ from openbb_core.provider.standard_models.historical_dividends import ( ) from yfinance import Ticker -_warn = warnings.warn - class YFinanceHistoricalDividendsQueryParams(HistoricalDividendsQueryParams): """YFinance Historical Dividends Query.""" diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/key_executives.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/key_executives.py index a36cf2f30ae..d1881726b97 100644 --- a/openbb_platform/providers/yfinance/openbb_yfinance/models/key_executives.py +++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/key_executives.py @@ -1,7 +1,6 @@ """YFinance Key Executives Model.""" # pylint: disable=unused-argument -import warnings from typing import Any, Dict, List, Optional from openbb_core.provider.abstract.fetcher import Fetcher @@ -12,12 +11,12 @@ from openbb_core.provider.standard_models.key_executives import ( from pydantic import Field from yfinance import Ticker -_warn = warnings.warn - class YFinanceKeyExecutivesQueryParams(KeyExecutivesQueryParams): """YFinance Key Executives Query.""" + __validator_dict__ = {"check_single": ("symbol",)} + class YFinanceKeyExecutivesData(KeyExecutivesData): """YFinance Key Executives Data.""" @@ -29,6 +28,7 @@ class YFinanceKeyExecutivesData(KeyExecutivesData): "exercised_value": "exercisedValue", "unexercised_value": "unexercisedValue", } + __validator_dict__ = {"check_single": ("symbol",)} exercised_value: Optional[int] = Field( default=None, @@ -57,19 +57,12 @@ class YFinanceKeyExecutivesFetcher( **kwargs: Any, ) -> List[Dict]: """Extract the raw data from YFinance.""" - symbols = query.symbol.split(",") - symbol = symbols[0] - if len(symbols) > 1: - _warn( - "Lists of symbols are not allowed for this function. " - f"Multiple symbols will be ignored in favour of the first symbol. {symbol}" - ) try: - ticker = Ticker(symbol).get_info() + ticker = Ticker(query.symbol).get_info() except Exception as e: - raise RuntimeError(f"Error getting data for {symbol}: {e}") from e + raise RuntimeError(f"Error getting data for {query.symbol}: {e}") from e if ticker.get("companyOfficers") is None: - raise ValueError(f"No executive data found for {symbol}") + raise ValueError(f"No executive data found for {query.symbol}") officers_data = ticker.get("companyOfficers", []) [d.pop("maxAge") for d in officers_data] # pylint: disable=W0106 return officers_data