From 3c67459bf1557de135c0db6c5b16e94088e06e66 Mon Sep 17 00:00:00 2001 From: timofey Date: Mon, 21 Nov 2022 01:11:40 +0000 Subject: [PATCH] replace optional with union --- ptvp35/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ptvp35/__init__.py b/ptvp35/__init__.py index b1c7702..4debb14 100644 --- a/ptvp35/__init__.py +++ b/ptvp35/__init__.py @@ -6,7 +6,7 @@ import pathlib import threading import traceback from io import StringIO, UnsupportedOperation -from typing import Any, Optional, IO, Hashable +from typing import Any, IO, Hashable __all__ = ( @@ -25,7 +25,7 @@ class Request: '__future', ) - def __init__(self, future: Optional[asyncio.Future], /) -> None: + def __init__(self, future: asyncio.Future | None, /) -> None: self.__future = future def waiting(self, /) -> bool: @@ -49,7 +49,7 @@ class LineRequest(Request): 'line', ) - def __init__(self, line: str, /, *, future: Optional[asyncio.Future]) -> None: + def __init__(self, line: str, /, *, future: asyncio.Future | None) -> None: super().__init__(future) self.line = line @@ -76,7 +76,7 @@ note: unstable signature.""" key, value = self.fromline(line) db[key] = value - def request(self, key: Any, value: Any, /, *, future: Optional[asyncio.Future]) -> 'KVRequest': + def request(self, key: Any, value: Any, /, *, future: asyncio.Future | None) -> 'KVRequest': """form request with Future. low-level API. note: unstable signature.""" @@ -95,7 +95,7 @@ class KVRequest(LineRequest): 'value', ) - def __init__(self, key: Any, value: Any, /, *, future: Optional[asyncio.Future], factory: KVFactory): + def __init__(self, key: Any, value: Any, /, *, future: asyncio.Future | None, factory: KVFactory): super().__init__(factory.line(key, value), future=future) self.__factory = factory self.key = key @@ -141,7 +141,7 @@ class TransactionRequest(LineRequest): 'buffer', ) - def __init__(self, buffer: StringIO, /, *, future: Optional[asyncio.Future]): + def __init__(self, buffer: StringIO, /, *, future: asyncio.Future | None): super().__init__(buffer.getvalue(), future=future) self.buffer = buffer @@ -393,13 +393,13 @@ note: unstable signature.""" self.__path_recover.unlink() self.__path_backup.unlink() - def _copy_sync(self, db: Optional[dict], /) -> None: + def _copy_sync(self, db: dict | None, /) -> None: if db is None: db = {} self._path2db_sync(self.__path_backup, db) self._db2path_sync(db, self.__path) - def _finish_recovery_sync(self, db: Optional[dict], /) -> None: + def _finish_recovery_sync(self, db: dict | None, /) -> None: self._copy_sync(db) self._recovery_unset_sync()