From 514a243e60991d75b6f2edba0ca37fe1408aba52 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 29 Aug 2023 12:05:45 +0100 Subject: [PATCH] fix qa/ta - mandatory provider_choices was breaking functions that don't really require it w @IgorWounds --- openbb_sdk/sdk/core/openbb_core/app/command_runner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openbb_sdk/sdk/core/openbb_core/app/command_runner.py b/openbb_sdk/sdk/core/openbb_core/app/command_runner.py index e4e79afbbaa..5e06f1706c8 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/command_runner.py +++ b/openbb_sdk/sdk/core/openbb_core/app/command_runner.py @@ -111,6 +111,7 @@ class ParametersBuilder: @staticmethod def update_provider_choices( + func: Callable, command_coverage: Dict[str, List[str]], route: str, kwargs: Dict[str, Any], @@ -118,6 +119,11 @@ class ParametersBuilder: ) -> Dict[str, Any]: """Update the provider choices with the available providers and set default provider.""" + def _needs_provider(func: Callable) -> bool: + """Check if the function needs a provider.""" + parameters = signature(func).parameters.keys() + return "provider_choices" in parameters + def _has_provider(kwargs: Dict[str, Any]) -> bool: """Check if the kwargs already have a provider.""" if ( @@ -146,7 +152,7 @@ class ParametersBuilder: return command_cov_provider - if not _has_provider(kwargs): + if not _has_provider(kwargs) and _needs_provider(func): provider = ( _get_default_provider( command_coverage, @@ -210,6 +216,7 @@ class ParametersBuilder: user_settings=user_settings, ) kwargs = cls.update_provider_choices( + func=func, command_coverage=command_map.command_coverage, route=route, kwargs=kwargs,