~naglis/aio_mpv_ipc

ffaa2495b8e6b9a2e239a8c2b8651f4bf2b9c19c — Naglis Jonaitis 9 months ago ef3338d
Drop pathlib.Path serialization
2 files changed, 3 insertions(+), 17 deletions(-)

M aio_mpv_ipc/_client.py
M tests/test_client.py
M aio_mpv_ipc/_client.py => aio_mpv_ipc/_client.py +2 -16
@@ 20,20 20,6 @@ IPC_ENCODING = "utf-8"
NEWLINE = b"\n"


def _json_serialize_default(o):
    if isinstance(o, pathlib.Path):
        return str(o)
    return o


def _default_json_loads(s: bytes):
    return json.loads(s.decode(encoding=IPC_ENCODING))


def _default_json_dumps(obj: typing.Any) -> str:
    return json.dumps(obj, default=_json_serialize_default)


@contextlib.asynccontextmanager
async def start_mpv(
    socket_path: typing.Union[pathlib.Path, str],


@@ 79,8 65,8 @@ class MpvClient:
        max_connect_attempts: int = 5,
        connect_sleep_timeout: float = 0.5,
        event_queue_timeout: float = 1.0,
        json_loads=_default_json_loads,
        json_dumps=_default_json_dumps,
        json_loads=json.loads,
        json_dumps=json.dumps,
    ) -> None:
        self._socket_path = socket_path
        self._reader, self._writer = None, None

M tests/test_client.py => tests/test_client.py +1 -1
@@ 9,7 9,7 @@ import pytest

import aio_mpv_ipc

TEST_FILE_SILENCE = pathlib.Path(__file__).parent / "test_data" / "silence.ogg"
TEST_FILE_SILENCE = str(pathlib.Path(__file__).parent / "test_data" / "silence.ogg")
TMP_FILE_PREFIX = "aio_mpv_ipc.test."

MPV_PATH = shutil.which("mpv")