fix qa/ta - mandatory provider_choices was breaking functions that don't really require it w @IgorWounds

This commit is contained in:
hjoaquim
2023-08-29 12:05:45 +01:00
parent a97c50e921
commit 514a243e60

View File

@@ -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,