diff --git a/src/syrupy/extensions/amber/__init__.py b/src/syrupy/extensions/amber/__init__.py index 74dbc33b..8d38d018 100644 --- a/src/syrupy/extensions/amber/__init__.py +++ b/src/syrupy/extensions/amber/__init__.py @@ -47,7 +47,7 @@ def delete_snapshots( else: Path(snapshot_location).unlink() - def _read_snapshot_collection(self, snapshot_location: str) -> "SnapshotCollection": + def _read_snapshot_collection(self, snapshot_location: str, **kwargs: Any) -> "SnapshotCollection": return self.serializer_class.read_file(snapshot_location) @classmethod @@ -72,7 +72,7 @@ def _read_snapshot_data_from_location( @classmethod def _write_snapshot_collection( - cls, *, snapshot_collection: "SnapshotCollection" + cls, *, snapshot_collection: "SnapshotCollection", **kwargs: Any ) -> None: cls.serializer_class.write_file(snapshot_collection, merge=True) diff --git a/src/syrupy/extensions/base.py b/src/syrupy/extensions/base.py index 945cf20b..97b33845 100644 --- a/src/syrupy/extensions/base.py +++ b/src/syrupy/extensions/base.py @@ -15,6 +15,7 @@ Optional, Set, Tuple, + Any, ) from syrupy.constants import ( @@ -67,6 +68,7 @@ def serialize( exclude: Optional["PropertyFilter"] = None, include: Optional["PropertyFilter"] = None, matcher: Optional["PropertyMatcher"] = None, + **kwargs: Any, ) -> "SerializedData": """ Serializes a python object / data structure into a string @@ -108,7 +110,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: Any ) -> "SnapshotCollections": """ Returns all snapshot collections in test site @@ -216,7 +218,7 @@ def delete_snapshots( @abstractmethod def _read_snapshot_collection( - self, *, snapshot_location: str + self, *, snapshot_location: str, **kwargs: Any ) -> "SnapshotCollection": """ Read the snapshot location and construct a snapshot collection object @@ -235,7 +237,7 @@ def _read_snapshot_data_from_location( @classmethod @abstractmethod def _write_snapshot_collection( - cls, *, snapshot_collection: "SnapshotCollection" + cls, *, snapshot_collection: "SnapshotCollection", **kwargs: Any ) -> None: """ Adds the snapshot data to the snapshots in collection location @@ -243,7 +245,9 @@ def _write_snapshot_collection( raise NotImplementedError @classmethod - def dirname(cls, *, test_location: "PyTestLocation") -> str: + def dirname( + cls, *, test_location: "PyTestLocation", **kwargs: Any + ) -> str: test_dir = Path(test_location.filepath).parent return str(test_dir.joinpath(SNAPSHOT_DIRNAME)) @@ -259,7 +263,10 @@ 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: Any, ) -> "SerializedData": env = {DISABLE_COLOR_ENV_VAR: "true"} attrs = {"_context_line_count": 0} @@ -267,7 +274,10 @@ 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: Any, ) -> Iterator[str]: for line in self.__diff_lines(str(snapshot_data), str(serialized_data)): yield reset(line) @@ -407,6 +417,7 @@ def matches( *, serialized_data: "SerializableData", snapshot_data: "SerializableData", + **kwargs: Any, ) -> bool: """ Compares serialized data and snapshot data and returns diff --git a/src/syrupy/extensions/json/__init__.py b/src/syrupy/extensions/json/__init__.py index 5b52a8d5..ccc9488e 100644 --- a/src/syrupy/extensions/json/__init__.py +++ b/src/syrupy/extensions/json/__init__.py @@ -145,6 +145,7 @@ def serialize( exclude: Optional["PropertyFilter"] = None, include: Optional["PropertyFilter"] = None, matcher: Optional["PropertyMatcher"] = None, + **kwargs: Any, ) -> "SerializedData": data = self._filter( data=data, diff --git a/src/syrupy/extensions/single_file.py b/src/syrupy/extensions/single_file.py index 0b216115..f405ffbf 100644 --- a/src/syrupy/extensions/single_file.py +++ b/src/syrupy/extensions/single_file.py @@ -1,13 +1,7 @@ from enum import Enum from gettext import gettext from pathlib import Path -from typing import ( - TYPE_CHECKING, - Optional, - Set, - Type, - Union, -) +from typing import TYPE_CHECKING, Optional, Set, Type, Union, Dict, Any from unicodedata import category from syrupy.constants import TEXT_ENCODING @@ -49,6 +43,7 @@ def serialize( exclude: Optional["PropertyFilter"] = None, include: Optional["PropertyFilter"] = None, matcher: Optional["PropertyMatcher"] = None, + **kwargs: Any, ) -> "SerializedData": return self.get_supported_dataclass()(data) @@ -74,12 +69,17 @@ def _get_file_basename( return cls.get_snapshot_name(test_location=test_location, index=index) @classmethod - def dirname(cls, *, test_location: "PyTestLocation") -> str: + def dirname( + cls, *, test_location: "PyTestLocation", **kwargs: Any + ) -> str: original_dirname = AbstractSyrupyExtension.dirname(test_location=test_location) return str(Path(original_dirname).joinpath(test_location.basename)) def _read_snapshot_collection( - self, *, snapshot_location: str + self, + *, + snapshot_location: str, + **kwargs: Any, ) -> "SnapshotCollection": file_ext_len = len(self._file_extension) + 1 if self._file_extension else 0 filename_wo_ext = snapshot_location[:-file_ext_len] @@ -116,7 +116,10 @@ def get_write_encoding(cls) -> Optional[str]: @classmethod def _write_snapshot_collection( - cls, *, snapshot_collection: "SnapshotCollection" + cls, + *, + snapshot_collection: "SnapshotCollection", + **kwargs: Any, ) -> None: filepath, data = ( snapshot_collection.location,