diff --git a/msgpack/__init__.py b/msgpack/__init__.py index 68fcf45..4a050ff 100644 --- a/msgpack/__init__.py +++ b/msgpack/__init__.py @@ -25,7 +25,7 @@ def pack(o: t.Any, stream: t.BinaryIO, **kwargs: dict[str, t.Any]): See :class:`Packer` for options. """ - packer = Packer(autoreset=True, **kwargs) # type: ignore + packer = Packer(autoreset=True, **kwargs) # type: ignore stream.write(t.cast(bytes, packer.pack(o))) @@ -35,7 +35,7 @@ def packb(o: t.Any, **kwargs: dict[str, t.Any]): See :class:`Packer` for options. """ - return Packer(autoreset=True, **kwargs).pack(o) # type: ignore + return Packer(autoreset=True, **kwargs).pack(o) # type: ignore def unpack(stream: t.BinaryIO, **kwargs: dict[str, t.Any]): diff --git a/msgpack/ext.py b/msgpack/ext.py index 7ee9cff..fe369b5 100644 --- a/msgpack/ext.py +++ b/msgpack/ext.py @@ -6,6 +6,7 @@ from collections import namedtuple class ExtType(namedtuple("ExtType", "code data")): """ExtType represents ext type in msgpack.""" + code: int data: bytes @@ -16,7 +17,7 @@ class ExtType(namedtuple("ExtType", "code data")): raise TypeError("data must be bytes") if not 0 <= code <= 127: raise ValueError("code must be 0~127") - return super().__new__(cls, code, data) # type: ignore + return super().__new__(cls, code, data) # type: ignore class Timestamp: diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 023c1e5..6931123 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -7,7 +7,7 @@ import typing as t from collections.abc import Sequence from datetime import datetime as _DateTime -_ClassInfo: t.TypeAlias = type | types.UnionType | tuple['_ClassInfo', ...] +_ClassInfo: t.TypeAlias = type | types.UnionType | tuple["_ClassInfo", ...] _Pair = tuple[t.Any, t.Any] _Pairs = t.Iterable[_Pair] _SizeFmt = tuple[int, str] @@ -90,7 +90,7 @@ def unpackb(packed: bytes, **kwargs: dict[str, t.Any]): See :class:`Unpacker` for options. """ - unpacker = Unpacker(None, max_buffer_size=len(packed), **kwargs) # type: ignore + unpacker = Unpacker(None, max_buffer_size=len(packed), **kwargs) # type: ignore unpacker.feed(packed) try: ret = unpacker._unpack() @@ -528,19 +528,20 @@ class Unpacker: return if self._object_pairs_hook is not None: ret = self._object_pairs_hook( - (self._unpack(EX_CONSTRUCT), self._unpack(EX_CONSTRUCT)) for _ in range(n) # type: ignore + (self._unpack(EX_CONSTRUCT), self._unpack(EX_CONSTRUCT)) + for _ in range(n) # type: ignore ) else: ret = {} for _ in range(n): key = self._unpack(EX_CONSTRUCT) if self._strict_map_key and type(key) not in (str, bytes): - raise ValueError("%s is not allowed for map key" % str(type(key))) # type: ignore + raise ValueError("%s is not allowed for map key" % str(type(key))) # type: ignore if isinstance(key, str): key = sys.intern(key) ret[key] = self._unpack(EX_CONSTRUCT) if self._object_hook is not None: - ret = self._object_hook(ret) # type: ignore + ret = self._object_hook(ret) # type: ignore return ret if execute == EX_SKIP: return