From f5b3c4c0a25d8a5624c0fda540391fd920c439a3 Mon Sep 17 00:00:00 2001 From: atharva-2001 Date: Mon, 25 Sep 2023 13:58:12 +0530 Subject: [PATCH] Add kwargs to AbstractSyrupyExtension classes --- src/syrupy/extensions/base.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/syrupy/extensions/base.py b/src/syrupy/extensions/base.py index 945cf20ba..fbd243f8d 100644 --- a/src/syrupy/extensions/base.py +++ b/src/syrupy/extensions/base.py @@ -67,6 +67,7 @@ def serialize( exclude: Optional["PropertyFilter"] = None, include: Optional["PropertyFilter"] = None, matcher: Optional["PropertyMatcher"] = None, + **kwargs ) -> "SerializedData": """ Serializes a python object / data structure into a string @@ -108,7 +109,7 @@ def is_snapshot_location(self, *, location: str) -> bool: return location.endswith(self._file_extension) def discover_snapshots( - self, *, test_location: "PyTestLocation" + self, *, test_location: "PyTestLocation", **kwargs ) -> "SnapshotCollections": """ Returns all snapshot collections in test site @@ -216,7 +217,7 @@ def delete_snapshots( @abstractmethod def _read_snapshot_collection( - self, *, snapshot_location: str + self, *, snapshot_location: str, **kwargs ) -> "SnapshotCollection": """ Read the snapshot location and construct a snapshot collection object @@ -235,7 +236,7 @@ def _read_snapshot_data_from_location( @classmethod @abstractmethod def _write_snapshot_collection( - cls, *, snapshot_collection: "SnapshotCollection" + cls, *, snapshot_collection: "SnapshotCollection", **kwargs ) -> None: """ Adds the snapshot data to the snapshots in collection location @@ -243,7 +244,7 @@ def _write_snapshot_collection( raise NotImplementedError @classmethod - def dirname(cls, *, test_location: "PyTestLocation") -> str: + def dirname(cls, *, test_location: "PyTestLocation", **kwargs) -> str: test_dir = Path(test_location.filepath).parent return str(test_dir.joinpath(SNAPSHOT_DIRNAME)) @@ -259,7 +260,7 @@ class SnapshotReporter(ABC): _context_line_count = 1 def diff_snapshots( - self, serialized_data: "SerializedData", snapshot_data: "SerializedData" + self, serialized_data: "SerializedData", snapshot_data: "SerializedData", **kwargs ) -> "SerializedData": env = {DISABLE_COLOR_ENV_VAR: "true"} attrs = {"_context_line_count": 0} @@ -267,7 +268,7 @@ def diff_snapshots( return "\n".join(self.diff_lines(serialized_data, snapshot_data)) def diff_lines( - self, serialized_data: "SerializedData", snapshot_data: "SerializedData" + self, serialized_data: "SerializedData", snapshot_data: "SerializedData", **kwargs ) -> Iterator[str]: for line in self.__diff_lines(str(snapshot_data), str(serialized_data)): yield reset(line) @@ -407,6 +408,7 @@ def matches( *, serialized_data: "SerializableData", snapshot_data: "SerializableData", + **kwargs ) -> bool: """ Compares serialized data and snapshot data and returns