Skip to content

Commit a7451fc

Browse files
authored
refactor: polywrap-msgpack package (#180)
1 parent ab4139f commit a7451fc

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

packages/polywrap-msgpack/polywrap_msgpack/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
from .sanitize import *
1515

1616
__all__ = [
17+
# Serializer
1718
"msgpack_decode",
1819
"msgpack_encode",
20+
# Extensions
1921
"decode_ext_hook",
2022
"encode_ext_hook",
21-
"sanitize",
2223
"ExtensionTypes",
24+
# Sanitizers
25+
"sanitize",
26+
# Extention types
2327
"GenericMap",
28+
# Errors
2429
"MsgpackError",
2530
"MsgpackDecodeError",
2631
"MsgpackEncodeError",

packages/polywrap-msgpack/polywrap_msgpack/decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def msgpack_decode(val: bytes) -> Any:
4343
Any: any python object
4444
"""
4545
try:
46-
return msgpack.unpackb(
46+
return msgpack.unpackb( # pyright: ignore[reportUnknownMemberType]
4747
val, ext_hook=decode_ext_hook
48-
) # pyright: reportUnknownMemberType=false
48+
)
4949
except Exception as e:
5050
raise MsgpackDecodeError("Failed to decode msgpack data") from e

packages/polywrap-msgpack/polywrap_msgpack/encoder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ def encode_ext_hook(obj: Any) -> ExtType:
2828
return ExtType(
2929
ExtensionTypes.GENERIC_MAP.value,
3030
# pylint: disable=protected-access
31-
msgpack_encode(cast(GenericMap[Any, Any], obj)._map),
32-
) # pyright: reportPrivateUsage=false
31+
msgpack_encode(
32+
cast(
33+
GenericMap[Any, Any], obj
34+
)._map # pyright: ignore[reportPrivateUsage]
35+
),
36+
)
3337
raise MsgpackExtError(f"Object of type {type(obj)} is not supported")
3438

3539

packages/polywrap-msgpack/polywrap_msgpack/sanitize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def sanitize(value: Any) -> Any:
2222
if isinstance(value, GenericMap):
2323
dictionary: Dict[Any, Any] = cast(
2424
GenericMap[Any, Any], value
25-
)._map # pyright: reportPrivateUsage=false
25+
)._map # pyright: ignore[reportPrivateUsage]
2626
new_map: GenericMap[str, Any] = GenericMap({})
2727
for key, val in dictionary.items():
2828
if not isinstance(key, str):

0 commit comments

Comments
 (0)