Skip to content

Commit 26d3347

Browse files
committed
Attempt at type checking
1 parent f5b3c4c commit 26d3347

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/syrupy/extensions/base.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Optional,
1616
Set,
1717
Tuple,
18+
Any
1819
)
1920

2021
from syrupy.constants import (
@@ -67,7 +68,7 @@ def serialize(
6768
exclude: Optional["PropertyFilter"] = None,
6869
include: Optional["PropertyFilter"] = None,
6970
matcher: Optional["PropertyMatcher"] = None,
70-
**kwargs
71+
**kwargs: Dict[Any, Any],
7172
) -> "SerializedData":
7273
"""
7374
Serializes a python object / data structure into a string
@@ -109,7 +110,7 @@ def is_snapshot_location(self, *, location: str) -> bool:
109110
return location.endswith(self._file_extension)
110111

111112
def discover_snapshots(
112-
self, *, test_location: "PyTestLocation", **kwargs
113+
self, *, test_location: "PyTestLocation", **kwargs: Dict[Any, Any]
113114
) -> "SnapshotCollections":
114115
"""
115116
Returns all snapshot collections in test site
@@ -217,7 +218,7 @@ def delete_snapshots(
217218

218219
@abstractmethod
219220
def _read_snapshot_collection(
220-
self, *, snapshot_location: str, **kwargs
221+
self, *, snapshot_location: str, **kwargs: Dict[Any, Any]
221222
) -> "SnapshotCollection":
222223
"""
223224
Read the snapshot location and construct a snapshot collection object
@@ -236,15 +237,15 @@ def _read_snapshot_data_from_location(
236237
@classmethod
237238
@abstractmethod
238239
def _write_snapshot_collection(
239-
cls, *, snapshot_collection: "SnapshotCollection", **kwargs
240+
cls, *, snapshot_collection: "SnapshotCollection", **kwargs: Dict[Any, Any]
240241
) -> None:
241242
"""
242243
Adds the snapshot data to the snapshots in collection location
243244
"""
244245
raise NotImplementedError
245246

246247
@classmethod
247-
def dirname(cls, *, test_location: "PyTestLocation", **kwargs) -> str:
248+
def dirname(cls, *, test_location: "PyTestLocation", **kwargs: Dict[Any, Any]) -> str:
248249
test_dir = Path(test_location.filepath).parent
249250
return str(test_dir.joinpath(SNAPSHOT_DIRNAME))
250251

@@ -260,15 +261,21 @@ class SnapshotReporter(ABC):
260261
_context_line_count = 1
261262

262263
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],
264268
) -> "SerializedData":
265269
env = {DISABLE_COLOR_ENV_VAR: "true"}
266270
attrs = {"_context_line_count": 0}
267271
with env_context(**env), obj_attrs(self, attrs):
268272
return "\n".join(self.diff_lines(serialized_data, snapshot_data))
269273

270274
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],
272279
) -> Iterator[str]:
273280
for line in self.__diff_lines(str(snapshot_data), str(serialized_data)):
274281
yield reset(line)
@@ -408,7 +415,7 @@ def matches(
408415
*,
409416
serialized_data: "SerializableData",
410417
snapshot_data: "SerializableData",
411-
**kwargs
418+
**kwargs: Dict[Any, Any],
412419
) -> bool:
413420
"""
414421
Compares serialized data and snapshot data and returns

0 commit comments

Comments
 (0)