From 5032a00687ffb7a7565ced718b5c6c9701d9ce00 Mon Sep 17 00:00:00 2001 From: z3z1ma Date: Sat, 27 Jul 2024 21:22:24 -0700 Subject: [PATCH] fix: better exception for @resolve with no key --- src/cdf/core/configuration.py | 2 ++ tests/core/injector/test_config.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cdf/core/configuration.py b/src/cdf/core/configuration.py index 051c927..b363616 100644 --- a/src/cdf/core/configuration.py +++ b/src/cdf/core/configuration.py @@ -223,6 +223,8 @@ def apply_converters( raise ValueError( "Resolver instance not provided but found @resolve converter" ) + if transformed_value not in resolver: + raise ValueError(f"Key not found in resolver: {transformed_value}") transformed_value = resolver[transformed_value] continue transformed_value = _CONVERTERS[converter.lower()](transformed_value) diff --git a/tests/core/injector/test_config.py b/tests/core/injector/test_config.py index 3241c55..c50e132 100644 --- a/tests/core/injector/test_config.py +++ b/tests/core/injector/test_config.py @@ -83,3 +83,5 @@ def bar(user: str, password: str, database: str): bar_configured = resolver.resolve_defaults(bar) assert bar_configured() == ("someone", "secret", "test") + + assert "main_api" in resolver