15
15
Optional ,
16
16
Set ,
17
17
Tuple ,
18
+ Any
18
19
)
19
20
20
21
from syrupy .constants import (
@@ -67,7 +68,7 @@ def serialize(
67
68
exclude : Optional ["PropertyFilter" ] = None ,
68
69
include : Optional ["PropertyFilter" ] = None ,
69
70
matcher : Optional ["PropertyMatcher" ] = None ,
70
- ** kwargs
71
+ ** kwargs : Dict [ Any , Any ],
71
72
) -> "SerializedData" :
72
73
"""
73
74
Serializes a python object / data structure into a string
@@ -109,7 +110,7 @@ def is_snapshot_location(self, *, location: str) -> bool:
109
110
return location .endswith (self ._file_extension )
110
111
111
112
def discover_snapshots (
112
- self , * , test_location : "PyTestLocation" , ** kwargs
113
+ self , * , test_location : "PyTestLocation" , ** kwargs : Dict [ Any , Any ]
113
114
) -> "SnapshotCollections" :
114
115
"""
115
116
Returns all snapshot collections in test site
@@ -217,7 +218,7 @@ def delete_snapshots(
217
218
218
219
@abstractmethod
219
220
def _read_snapshot_collection (
220
- self , * , snapshot_location : str , ** kwargs
221
+ self , * , snapshot_location : str , ** kwargs : Dict [ Any , Any ]
221
222
) -> "SnapshotCollection" :
222
223
"""
223
224
Read the snapshot location and construct a snapshot collection object
@@ -236,15 +237,15 @@ def _read_snapshot_data_from_location(
236
237
@classmethod
237
238
@abstractmethod
238
239
def _write_snapshot_collection (
239
- cls , * , snapshot_collection : "SnapshotCollection" , ** kwargs
240
+ cls , * , snapshot_collection : "SnapshotCollection" , ** kwargs : Dict [ Any , Any ]
240
241
) -> None :
241
242
"""
242
243
Adds the snapshot data to the snapshots in collection location
243
244
"""
244
245
raise NotImplementedError
245
246
246
247
@classmethod
247
- def dirname (cls , * , test_location : "PyTestLocation" , ** kwargs ) -> str :
248
+ def dirname (cls , * , test_location : "PyTestLocation" , ** kwargs : Dict [ Any , Any ] ) -> str :
248
249
test_dir = Path (test_location .filepath ).parent
249
250
return str (test_dir .joinpath (SNAPSHOT_DIRNAME ))
250
251
@@ -260,15 +261,21 @@ class SnapshotReporter(ABC):
260
261
_context_line_count = 1
261
262
262
263
def diff_snapshots (
263
- self , serialized_data : "SerializedData" , snapshot_data : "SerializedData" , ** kwargs
264
+ self ,
265
+ serialized_data : "SerializedData" ,
266
+ snapshot_data : "SerializedData" ,
267
+ ** kwargs : Dict [Any , Any ],
264
268
) -> "SerializedData" :
265
269
env = {DISABLE_COLOR_ENV_VAR : "true" }
266
270
attrs = {"_context_line_count" : 0 }
267
271
with env_context (** env ), obj_attrs (self , attrs ):
268
272
return "\n " .join (self .diff_lines (serialized_data , snapshot_data ))
269
273
270
274
def diff_lines (
271
- self , serialized_data : "SerializedData" , snapshot_data : "SerializedData" , ** kwargs
275
+ self ,
276
+ serialized_data : "SerializedData" ,
277
+ snapshot_data : "SerializedData" ,
278
+ ** kwargs : Dict [Any , Any ],
272
279
) -> Iterator [str ]:
273
280
for line in self .__diff_lines (str (snapshot_data ), str (serialized_data )):
274
281
yield reset (line )
@@ -408,7 +415,7 @@ def matches(
408
415
* ,
409
416
serialized_data : "SerializableData" ,
410
417
snapshot_data : "SerializableData" ,
411
- ** kwargs
418
+ ** kwargs : Dict [ Any , Any ],
412
419
) -> bool :
413
420
"""
414
421
Compares serialized data and snapshot data and returns
0 commit comments