Skip to content

Commit 99512b8

Browse files
committed
Use JSON response value types
1 parent dcaf38f commit 99512b8

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/mock_vws/_model_target_web_api.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
OAuth2ClientCredential,
2727
)
2828

29+
type _JSONValue = (
30+
bool | int | float | str | list[_JSONValue] | dict[str, _JSONValue] | None
31+
)
32+
2933
_ResponseType = tuple[int, dict[str, str], str | bytes]
3034

3135

@@ -806,21 +810,21 @@ def delete_oauth2_client_credential(
806810

807811

808812
@beartype
809-
def _is_json_object(value: object, /) -> TypeGuard[dict[str, object]]:
813+
def _is_json_object(value: object, /) -> TypeGuard[dict[str, _JSONValue]]:
810814
"""Return whether a decoded JSON value is an object."""
811-
return TypeHint(hint=dict[str, object]).is_bearable(obj=value)
815+
return TypeHint(hint=dict[str, _JSONValue]).is_bearable(obj=value)
812816

813817

814818
@beartype
815-
def _is_json_array(value: object, /) -> TypeGuard[list[object]]:
819+
def _is_json_array(value: object, /) -> TypeGuard[list[_JSONValue]]:
816820
"""Return whether a decoded JSON value is an array."""
817-
return isinstance(value, list)
821+
return TypeHint(hint=list[_JSONValue]).is_bearable(obj=value)
818822

819823

820824
@beartype
821825
def _load_request_json(
822826
request: RequestData,
823-
) -> dict[str, object] | _ResponseType:
827+
) -> dict[str, _JSONValue] | _ResponseType:
824828
"""Load a Model Target dataset creation request body."""
825829
content_type_header = _get_header(request=request, name="Content-Type")
826830
content_type = (

0 commit comments

Comments
 (0)