diff --git a/hathor/event/websocket/request.py b/hathor/event/websocket/request.py index c4c5efd04..446c62840 100644 --- a/hathor/event/websocket/request.py +++ b/hathor/event/websocket/request.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Literal, Optional, Union +from typing import Annotated, Literal, Optional, Union -from pydantic import NonNegativeInt +from pydantic import Field, NonNegativeInt from hathor.utils.pydantic import BaseModel @@ -54,9 +54,7 @@ class StopStreamRequest(BaseModel): type: Literal['STOP_STREAM'] -# This could be more performatic in Python 3.9: -# Request = Annotated[StartStreamRequest | AckRequest | StopStreamRequest, Field(discriminator='type')] -Request = Union[StartStreamRequest, AckRequest, StopStreamRequest] +Request = Annotated[Union[StartStreamRequest, AckRequest, StopStreamRequest], Field(discriminator='type')] class RequestWrapper(BaseModel): diff --git a/hathor/indexes/rocksdb_utils.py b/hathor/indexes/rocksdb_utils.py index ad1a94325..3a98fed2d 100644 --- a/hathor/indexes/rocksdb_utils.py +++ b/hathor/indexes/rocksdb_utils.py @@ -121,8 +121,7 @@ def _clone_into_dict(self) -> Dict[bytes, bytes]: return {k: v for (_, k), v in it} -# XXX: should be `Collection[bytes]`, which only works on Python 3.9+ -class RocksDBSimpleSet(Collection, RocksDBIndexUtils): +class RocksDBSimpleSet(Collection[bytes], RocksDBIndexUtils): def __init__(self, db: 'rocksdb.DB', log: 'structlog.stdlib.BoundLogger', *, cf_name: bytes) -> None: self.log = log super().__init__(db, cf_name)