diff --git a/src/pvframework/utils/query_object.py b/src/pvframework/utils/query_object.py index 0c0d368..78c6b07 100644 --- a/src/pvframework/utils/query_object.py +++ b/src/pvframework/utils/query_object.py @@ -24,12 +24,14 @@ def optional_field(obj: Any, attribute_path: str, attribute_type: type[AttrT]) - @overload -def required_field(obj: Any, attribute_path: str, attribute_type: type[AttrT]) -> AttrT: +def required_field( + obj: Any, attribute_path: str, attribute_type: type[AttrT], param_base_path: Optional[str] = None +) -> AttrT: ... @overload -def required_field(obj: Any, attribute_path: str, attribute_type: Any) -> Any: +def required_field(obj: Any, attribute_path: str, attribute_type: Any, param_base_path: Optional[str] = None) -> Any: ... diff --git a/unittests/test_validation.py b/unittests/test_validation.py index 1f6f68f..ed2c6a1 100644 --- a/unittests/test_validation.py +++ b/unittests/test_validation.py @@ -91,7 +91,7 @@ def check_required_and_optional(zx: str, zz: str | None = None) -> None: def check_required_and_optional_with_utility(z: Wrapper) -> None: - assert required_field(z, "x", str) == "Hello" + assert required_field(z, "x", str, param_base_path=param("z").param_id) == "Hello" assert optional_field(z, "z", str) is None