Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/polywrap-msgpack/polywrap_msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
from .sanitize import *

__all__ = [
# Serializer
"msgpack_decode",
"msgpack_encode",
# Extensions
"decode_ext_hook",
"encode_ext_hook",
"sanitize",
"ExtensionTypes",
# Sanitizers
"sanitize",
# Extention types
"GenericMap",
# Errors
"MsgpackError",
"MsgpackDecodeError",
"MsgpackEncodeError",
Expand Down
4 changes: 2 additions & 2 deletions packages/polywrap-msgpack/polywrap_msgpack/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def msgpack_decode(val: bytes) -> Any:
Any: any python object
"""
try:
return msgpack.unpackb(
return msgpack.unpackb( # pyright: ignore[reportUnknownMemberType]
val, ext_hook=decode_ext_hook
) # pyright: reportUnknownMemberType=false
)
except Exception as e:
raise MsgpackDecodeError("Failed to decode msgpack data") from e
8 changes: 6 additions & 2 deletions packages/polywrap-msgpack/polywrap_msgpack/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ def encode_ext_hook(obj: Any) -> ExtType:
return ExtType(
ExtensionTypes.GENERIC_MAP.value,
# pylint: disable=protected-access
msgpack_encode(cast(GenericMap[Any, Any], obj)._map),
) # pyright: reportPrivateUsage=false
msgpack_encode(
cast(
GenericMap[Any, Any], obj
)._map # pyright: ignore[reportPrivateUsage]
),
)
raise MsgpackExtError(f"Object of type {type(obj)} is not supported")


Expand Down
2 changes: 1 addition & 1 deletion packages/polywrap-msgpack/polywrap_msgpack/sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def sanitize(value: Any) -> Any:
if isinstance(value, GenericMap):
dictionary: Dict[Any, Any] = cast(
GenericMap[Any, Any], value
)._map # pyright: reportPrivateUsage=false
)._map # pyright: ignore[reportPrivateUsage]
new_map: GenericMap[str, Any] = GenericMap({})
for key, val in dictionary.items():
if not isinstance(key, str):
Expand Down