@@ -215,6 +215,7 @@ def read_test_results(self) -> bytes:
215215
216216 @overload
217217 def __call__ (self , data_to_snapshot : dict , name : str | None = None , filetype : str | None = None ) -> DictExpect : ...
218+
218219 @overload
219220 def __call__ (
220221 self ,
@@ -236,7 +237,10 @@ def __call__(
236237
237238 @overload
238239 def __call__ (
239- self , data_to_snapshot : DataframeExpect .DataFrame , name : str | None = None , filetype : str | None = None ,
240+ self ,
241+ data_to_snapshot : DataframeExpect .DataFrame ,
242+ name : str | None = None ,
243+ filetype : str | None = None ,
240244 ) -> DataframeExpect : ...
241245
242246 def __call__ (
@@ -261,13 +265,14 @@ def __call__(
261265 }
262266
263267 for typ , func in type_map .items ():
264- if isinstance (data_to_snapshot , typ ):
268+ if isinstance (typ , type ) and isinstance ( data_to_snapshot , typ ):
265269 return func (data_to_snapshot , ** kwargs )
266270
267- error_message = f"Unsupported type { type (data_to_snapshot )} . Expected one of: dict, list, str, bytes, DataFrame."
268- raise TypeError (
269- error_message ,
270- )
271+ supported_types : list [str ] = [
272+ getattr (typ , "__name__" , str (typ )) if isinstance (typ , type ) else typ for typ in type_map .keys () # noqa: SIM118
273+ ]
274+ error_message = f"Unsupported type: { type (data_to_snapshot )} . Supported types: { ', ' .join (supported_types )} ."
275+ raise TypeError (error_message )
271276
272277
273278class LoadSnapshot :
@@ -312,5 +317,5 @@ def dataframe(self) -> DataframeExpect.DataFrame:
312317 """Load dataframe snapshot."""
313318 self .settings .depending_filename_extension = "dataframe.json"
314319 return DataframeExpect .DataFrame (
315- JsonPickleSerializer [DataframeExpect .DataFrame ]().deserialize (self ._read_snapshot ())
320+ JsonPickleSerializer [DataframeExpect .DataFrame ]().deserialize (self ._read_snapshot ()),
316321 )
0 commit comments