Skip to content

Commit

Permalink
Fix missing overload variants for required_field
Browse files Browse the repository at this point in the history
  • Loading branch information
lord-haffi committed Jan 14, 2024
1 parent ed7cb71 commit 3f0e442
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/pvframework/utils/query_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
...


Expand Down
2 changes: 1 addition & 1 deletion unittests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 3f0e442

Please sign in to comment.