1111from beartype import BeartypeConf , beartype
1212from beartype .door import TypeHint
1313
14+ from vws .json_types import JSONValue
15+
1416
1517def _checked [T ](value : object , hint : type [T ], / ) -> T :
1618 """Return a value after checking its runtime type."""
@@ -64,7 +66,9 @@ class DatabaseSummaryReport:
6466 total_recos : int
6567
6668 @classmethod
67- def from_response_dict (cls , response_dict : Mapping [str , object ]) -> Self :
69+ def from_response_dict (
70+ cls , response_dict : Mapping [str , JSONValue ]
71+ ) -> Self :
6872 """Construct from a VWS API response dict."""
6973 return cls (
7074 active_images = int (_number (response_dict ["active_images" ])),
@@ -120,7 +124,9 @@ class TargetSummaryReport:
120124 previous_month_recos : int
121125
122126 @classmethod
123- def from_response_dict (cls , response_dict : Mapping [str , object ]) -> Self :
127+ def from_response_dict (
128+ cls , response_dict : Mapping [str , JSONValue ]
129+ ) -> Self :
124130 """Construct from a VWS API response dict."""
125131 return cls (
126132 status = TargetStatuses (
@@ -185,13 +191,13 @@ class QueryResult:
185191 @classmethod
186192 def from_response_dict (
187193 cls ,
188- response_dict : Mapping [str , object ],
194+ response_dict : Mapping [str , JSONValue ],
189195 ) -> Self :
190196 """Construct from a VWS API query result item dict."""
191197 target_data : TargetData | None = None
192198 if "target_data" in response_dict :
193199 target_data_dict = _checked (
194- response_dict ["target_data" ], dict [str , object ]
200+ response_dict ["target_data" ], dict [str , JSONValue ]
195201 )
196202 target_timestamp = datetime .datetime .fromtimestamp (
197203 timestamp = _number (target_data_dict ["target_timestamp" ]),
@@ -223,11 +229,13 @@ class TargetStatusAndRecord:
223229 target_record : TargetRecord
224230
225231 @classmethod
226- def from_response_dict (cls , response_dict : Mapping [str , object ]) -> Self :
232+ def from_response_dict (
233+ cls , response_dict : Mapping [str , JSONValue ]
234+ ) -> Self :
227235 """Construct from a VWS API response dict."""
228236 status = TargetStatuses (value = _checked (response_dict ["status" ], str ))
229237 target_record_dict = _checked (
230- response_dict ["target_record" ], dict [str , object ]
238+ response_dict ["target_record" ], dict [str , JSONValue ]
231239 )
232240 target_record = TargetRecord (
233241 target_id = _checked (target_record_dict ["target_id" ], str ),
@@ -260,7 +268,9 @@ class RecoCountsReportRequest:
260268 """
261269
262270 @classmethod
263- def from_response_dict (cls , response_dict : Mapping [str , object ]) -> Self :
271+ def from_response_dict (
272+ cls , response_dict : Mapping [str , JSONValue ]
273+ ) -> Self :
264274 """Construct from a VWS API response dict."""
265275 return cls (
266276 transaction_id = _checked (response_dict ["transaction_id" ], str ),
@@ -353,12 +363,12 @@ class ModelTargetDatasetStatusReport:
353363 @classmethod
354364 def from_response_dict (
355365 cls ,
356- response_dict : Mapping [str , object ],
366+ response_dict : Mapping [str , JSONValue ],
357367 ) -> Self :
358368 """Construct from a Model Target Web API response dict."""
359369 error : ModelTargetGenerationError | None = None
360370 if "error" in response_dict :
361- error_dict = _checked (response_dict ["error" ], dict [str , object ])
371+ error_dict = _checked (response_dict ["error" ], dict [str , JSONValue ])
362372 error = ModelTargetGenerationError (
363373 code = _checked (error_dict ["code" ], str ),
364374 message = _checked (error_dict ["message" ], str ),
@@ -367,10 +377,10 @@ def from_response_dict(
367377 warning : ModelTargetGenerationWarning | None = None
368378 if "warning" in response_dict :
369379 warning_dict = _checked (
370- response_dict ["warning" ], dict [str , object ]
380+ response_dict ["warning" ], dict [str , JSONValue ]
371381 )
372382 details = _checked (
373- warning_dict ["details" ], list [dict [str , object ]]
383+ warning_dict ["details" ], list [dict [str , JSONValue ]]
374384 )
375385 warning = ModelTargetGenerationWarning (
376386 code = _checked (warning_dict ["code" ], str ),
0 commit comments