From 5efa9d18d9481ce0c8f20dd75eadca2ae68bca87 Mon Sep 17 00:00:00 2001 From: montezdesousa Date: Mon, 10 Jul 2023 02:22:24 +0100 Subject: [PATCH] make extra_params mandatory --- .../fixedincome/fixedincome_router.py | 7 ++++- .../builtin_extensions/stocks/dd/dd_router.py | 7 ++++- .../builtin_extensions/stocks/fa/fa_router.py | 26 ++++++++++++++++++- .../openbb_sdk_core/app/router.py | 17 ++++++------ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py b/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py index 4ab04a8c66d..b5ed3a19247 100644 --- a/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py +++ b/openbb_sdk/builtin_extensions/fixedincome/fixedincome_router.py @@ -3,7 +3,11 @@ from openbb_sdk_core.app.model.command_context import CommandContext from openbb_sdk_core.app.model.command_output import CommandOutput from openbb_sdk_core.app.model.results.empty import Empty -from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams +from openbb_sdk_core.app.provider_interface import ( + ExtraParams, + ProviderChoices, + StandardParams, +) from openbb_sdk_core.app.query import Query from openbb_sdk_core.app.router import Router from pydantic import BaseModel @@ -16,6 +20,7 @@ def treasury( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Get treasury rates.""" return CommandOutput(results=Query(**locals()).execute()) diff --git a/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py b/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py index 7cac3149e7b..657087ee729 100644 --- a/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py +++ b/openbb_sdk/builtin_extensions/stocks/dd/dd_router.py @@ -3,7 +3,11 @@ from openbb_sdk_core.app.model.command_context import CommandContext from openbb_sdk_core.app.model.command_output import CommandOutput -from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams +from openbb_sdk_core.app.provider_interface import ( + ExtraParams, + ProviderChoices, + StandardParams, +) from openbb_sdk_core.app.query import Query from openbb_sdk_core.app.router import Router from pydantic import BaseModel @@ -16,6 +20,7 @@ def sec( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """SEC Filings.""" return CommandOutput(results=Query(**locals()).execute()) diff --git a/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py b/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py index a8c3bd34ebf..45930113ad0 100644 --- a/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py +++ b/openbb_sdk/builtin_extensions/stocks/fa/fa_router.py @@ -4,7 +4,11 @@ from openbb_sdk_core.app.model.command_context import CommandContext from openbb_sdk_core.app.model.command_output import CommandOutput from openbb_sdk_core.app.model.results.empty import Empty -from openbb_sdk_core.app.provider_interface import ProviderChoices, StandardParams +from openbb_sdk_core.app.provider_interface import ( + ExtraParams, + ProviderChoices, + StandardParams, +) from openbb_sdk_core.app.query import Query from openbb_sdk_core.app.router import Router from pydantic import BaseModel @@ -17,6 +21,7 @@ def balance( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Balance Sheet.""" return CommandOutput(results=Query(**locals()).execute()) @@ -27,6 +32,7 @@ def cash( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Cash Flow Statement.""" return CommandOutput(results=Query(**locals()).execute()) @@ -37,6 +43,7 @@ def comp( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Executive Compensation.""" return CommandOutput(results=Query(**locals()).execute()) @@ -47,6 +54,7 @@ def earning( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Earnings Calendar.""" return CommandOutput(results=Query(**locals()).execute()) @@ -63,6 +71,7 @@ def est( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Analyst Estimates.""" return CommandOutput(results=Query(**locals()).execute()) @@ -73,6 +82,7 @@ def income( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Income Statement.""" return CommandOutput(results=Query(**locals()).execute()) @@ -83,6 +93,7 @@ def ins( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Stock Insider Trading.""" return CommandOutput(results=Query(**locals()).execute()) @@ -93,6 +104,7 @@ def metrics( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Key Metrics.""" return CommandOutput(results=Query(**locals()).execute()) @@ -103,6 +115,7 @@ def mgmt( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Key Executives.""" return CommandOutput(results=Query(**locals()).execute()) @@ -113,6 +126,7 @@ def overview( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Company Overview.""" return CommandOutput(results=Query(**locals()).execute()) @@ -123,6 +137,7 @@ def own( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Institutional Ownership.""" return CommandOutput(results=Query(**locals()).execute()) @@ -133,6 +148,7 @@ def pta( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Price Target.""" return CommandOutput(results=Query(**locals()).execute()) @@ -143,6 +159,7 @@ def pt( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Price Target Consensus.""" return CommandOutput(results=Query(**locals()).execute()) @@ -153,6 +170,7 @@ def revgeo( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Revenue Geographic.""" return CommandOutput(results=Query(**locals()).execute()) @@ -163,6 +181,7 @@ def revseg( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Revenue Business Line.""" return CommandOutput(results=Query(**locals()).execute()) @@ -173,6 +192,7 @@ def shrs( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Share Statistics.""" return CommandOutput(results=Query(**locals()).execute()) @@ -188,6 +208,7 @@ def transcript( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Earnings Call Transcript.""" return CommandOutput(results=Query(**locals()).execute()) @@ -198,6 +219,7 @@ def split( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Historical Stock Splits.""" return CommandOutput(results=Query(**locals()).execute()) @@ -208,6 +230,7 @@ def cal( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Historical Dividends.""" return CommandOutput(results=Query(**locals()).execute()) @@ -218,6 +241,7 @@ def comsplit( cc: CommandContext, provider_choices: ProviderChoices, standard_params: StandardParams, + extra_params: ExtraParams, ) -> CommandOutput[BaseModel]: """Stock Split Calendar.""" return CommandOutput(results=Query(**locals()).execute()) diff --git a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py index 76bc2ba1e14..1a8a1a63898 100644 --- a/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py +++ b/openbb_sdk/openbb_sdk_core/openbb_sdk_core/app/router.py @@ -283,16 +283,15 @@ class SignatureInspector: f"Invalid signature: {func.__name__}. standard_params parameter must be of type StandardParams." ) - # TODO: Uncomment if we want extra_params to be mandatory - # if "extra_params" not in func.__annotations__: - # raise AttributeError( - # f"Invalid signature: {func.__name__}. Missing extra_params parameter." - # ) + if "extra_params" not in func.__annotations__: + raise AttributeError( + f"Invalid signature: {func.__name__}. Missing extra_params parameter." + ) - # if func.__annotations__["extra_params"] != ExtraParams: - # raise TypeError( - # f"Invalid signature: {func.__name__}. extra_params parameter must be of type ExtraParams." - # ) + if func.__annotations__["extra_params"] != ExtraParams: + raise TypeError( + f"Invalid signature: {func.__name__}. extra_params parameter must be of type ExtraParams." + ) @staticmethod def inject_dependency(