diff --git a/eodhd/apiclient.py b/eodhd/apiclient.py index bece975..bebfe78 100644 --- a/eodhd/apiclient.py +++ b/eodhd/apiclient.py @@ -706,8 +706,13 @@ def get_insider_transactions_data( def get_fundamentals_data(self, ticker: str, filter: str = None, historical: int = None, from_date: str = None, to_date: str = None, version: int = None, - no_cache: int = None) -> list: - """GET /api/fundamentals/{ticker}""" + no_cache: int = None) -> dict: + """GET /api/fundamentals/{ticker} + + Returns the parsed JSON object. Note: a ``filter`` that narrows below the + top level reshapes the response (e.g. ``General::Code`` returns a scalar + string), so the ``-> dict`` hint reflects the common unfiltered / top-level + section case rather than every possible filter shape (see issue #71).""" api_call = FundamentalDataAPI(session=self._session, timeout=self._timeout) return api_call.get_fundamentals_data( api_token=self._api_key, ticker=ticker, filter=filter, historical=historical, @@ -716,8 +721,13 @@ def get_fundamentals_data(self, ticker: str, filter: str = None, historical: int def get_fundamentals_data_v1_1(self, ticker: str, filter: str = None, historical: int = None, from_date: str = None, to_date: str = None, version: int = None, - no_cache: int = None) -> list: - """GET /api/v1.1/fundamentals/{ticker} — uses improved Earnings::Trend data""" + no_cache: int = None) -> dict: + """GET /api/v1.1/fundamentals/{ticker} — uses improved Earnings::Trend data + + Returns the parsed JSON object. Note: a ``filter`` that narrows below the + top level reshapes the response (e.g. ``General::Code`` returns a scalar + string), so the ``-> dict`` hint reflects the common unfiltered / top-level + section case rather than every possible filter shape (see issue #71).""" api_call = FundamentalDataAPI(session=self._session, timeout=self._timeout) return api_call.get_fundamentals_data_v1_1( api_token=self._api_key, ticker=ticker, filter=filter, historical=historical, diff --git a/tests/test_fundamentaldataapi.py b/tests/test_fundamentaldataapi.py index b9bd358..cb36b55 100644 --- a/tests/test_fundamentaldataapi.py +++ b/tests/test_fundamentaldataapi.py @@ -1,6 +1,10 @@ """Unit tests for FundamentalDataAPI""" +import inspect + import pytest + +from eodhd.apiclient import APIClient from eodhd.APIs import FundamentalDataAPI @@ -25,3 +29,11 @@ def test_get_fundamentals_data_v1_1_method_exists(): api = FundamentalDataAPI() assert hasattr(api, "get_fundamentals_data_v1_1") assert callable(api.get_fundamentals_data_v1_1) + + +def test_get_fundamentals_data_return_annotation_is_dict(): + """The /fundamentals endpoint returns a JSON object, so the client methods + must be annotated -> dict, not -> list (see issue #71).""" + client = APIClient.__new__(APIClient) + assert inspect.signature(client.get_fundamentals_data).return_annotation is dict + assert inspect.signature(client.get_fundamentals_data_v1_1).return_annotation is dict