From f1b4d36e35a6f53f66d76649103ff40f4b7ec106 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:40:06 -0800 Subject: [PATCH] improve docstring (#6986) --- openbb_platform/openbb/assets/reference.json | 2 +- openbb_platform/openbb/package/fixedincome.py | 30 ++++++++++++++++++- .../fred/openbb_fred/models/bond_indices.py | 20 ++++++++----- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 5020528634f..1d875fc9579 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -39188,7 +39188,7 @@ { "name": "index", "type": "Union[str, List[str]]", - "description": "The specific index to query. Used in conjunction with 'category' and 'index_type', default is 'yield_curve'. Multiple items allowed for provider(s): fred.", + "description": "The specific index to query. Used in conjunction with 'category' and 'index_type', default is 'yield_curve'.\n Possible values are:\n corporate\n seasoned_corporate\n liquid_corporate\n yield_curve\n crossover\n public_sector\n private_sector\n non_financial\n high_grade\n high_yield\n liquid_emea\n emea\n liquid_asia\n asia\n liquid_latam\n latam\n liquid_aaa\n liquid_bbb\n aaa\n aa\n a\n bbb\n bb\n b\n ccc Multiple items allowed for provider(s): fred.", "default": "yield_curve", "optional": true, "choices": [ diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 484ec2f06fc..f1a37996b1e 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -68,7 +68,35 @@ class ROUTER_fixedincome(Container): category : Literal['high_yield', 'us', 'emerging_markets'] The type of index category. Used in conjunction with 'index', default is 'us'. (provider: fred) index : str - The specific index to query. Used in conjunction with 'category' and 'index_type', default is 'yield_curve'. Multiple comma separated items allowed. (provider: fred) + The specific index to query. Used in conjunction with 'category' and 'index_type', default is 'yield_curve'. + Possible values are: + corporate + seasoned_corporate + liquid_corporate + yield_curve + crossover + public_sector + private_sector + non_financial + high_grade + high_yield + liquid_emea + emea + liquid_asia + asia + liquid_latam + latam + liquid_aaa + liquid_bbb + aaa + aa + a + bbb + bb + b + ccc + + Multiple comma separated items allowed. (provider: fred) frequency : Optional[Literal['a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] Frequency aggregation to convert daily data to lower frequency. diff --git a/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py b/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py index a47d697ab8b..40f3a465f27 100644 --- a/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py +++ b/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py @@ -290,6 +290,8 @@ INDEX_CHOICES = [ "ccc", ] +index_choices_str = "\n ".join(INDEX_CHOICES) + class FredBondIndicesQueryParams(BondIndicesQueryParams): """FRED Bond Indices Query.""" @@ -308,7 +310,11 @@ class FredBondIndicesQueryParams(BondIndicesQueryParams): index: str = Field( default="yield_curve", description="The specific index to query." - + " Used in conjunction with 'category' and 'index_type', default is 'yield_curve'.", + + " Used in conjunction with 'category' and 'index_type', default is 'yield_curve'." + + f""" + Possible values are: + {index_choices_str}\n + """, ) frequency: Union[ None, @@ -455,8 +461,8 @@ class FredBondIndicesFetcher( if values["category"] == "us": if index not in BAML_CATEGORIES.get("us"): # type: ignore message = ( - "Invalid index for category: 'us'." - + f" Must be one of {','.join(BAML_CATEGORIES.get('us'))}." # type: ignore + f"Invalid index, {index}, for category: 'us'." + + f" Must be one of {', '.join(BAML_CATEGORIES.get('us'))}." # type: ignore ) messages.append(message) elif ( @@ -473,8 +479,8 @@ class FredBondIndicesFetcher( if values["category"] == "high_yield": if index not in ("us", "europe", "emerging"): message = ( - "Invalid index for category: 'high_yield'." - + f" Must be one of {','.join(BAML_CATEGORIES.get('high_yield', ''))}." # type: ignore + f"Invalid index, {index}, for category: 'high_yield'." + + f" Must be one of {', '.join(BAML_CATEGORIES.get('high_yield', ''))}." # type: ignore ) messages.append(message) else: @@ -482,8 +488,8 @@ class FredBondIndicesFetcher( if values["category"] == "emerging_markets": if index not in BAML_CATEGORIES.get("emerging_markets"): # type: ignore message = ( - "Invalid index for category: 'emerging_markets'." - + f" Must be one of {','.join(BAML_CATEGORIES.get('emerging_markets', ''))}." # type: ignore + f"Invalid index, {index}, for category: 'emerging_markets'." + + f" Must be one of {', '.join(BAML_CATEGORIES.get('emerging_markets', ''))}." # type: ignore ) messages.append(message) else: