Open
Description
I was looking into making a custom serializer and I was having trouble figuring out typing.
It's probably a good idea to make abstract classes with clear typing to make implementation easier.
Here's what I came up with:
import os
from abc import ABC, abstractmethod
from vcr.request import Request
class VcrPySerializer(ABC):
@abstractmethod
def deserialize(
self,
cassette_string: str
) -> dict:
pass
@abstractmethod
def serialize(
self,
cassette_dict: dict
) -> str:
pass
class VcrPyPersister(ABC):
@abstractmethod
@classmethod
def load_cassette(
cls,
cassette_path: str | bytes | os.PathLike,
serializer: VcrPySerializer
)-> tuple[list[Request], list[bytes]]:
pass
@abstractmethod
@staticmethod
def save_cassette(
cassette_path: str | bytes | os.PathLike,
cassette_dict: dict,
serializer: VcrPySerializer
) -> None:
pass
Metadata
Metadata
Assignees
Labels
No labels