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
3 changes: 3 additions & 0 deletions packages/polywrap-manifest/polywrap_manifest/deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ def deserialize_wrap_manifest(
raise NotImplementedError(
f"Version {manifest_version.value} is not implemented"
)


__all__ = ["deserialize_wrap_manifest"]
3 changes: 3 additions & 0 deletions packages/polywrap-manifest/polywrap_manifest/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ class ManifestError(Exception):

class DeserializeManifestError(ManifestError):
"""Raised when a manifest cannot be deserialized."""


__all__ = ["ManifestError", "DeserializeManifestError"]
32 changes: 21 additions & 11 deletions packages/polywrap-manifest/polywrap_manifest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ class DeserializeManifestOptions:
no_validate: Optional[bool] = None


@dataclass(slots=True, kw_only=True)
class SerializeManifestOptions:
"""Options for serializing a manifest to msgpack encoded bytes.

Attributes:
no_validate: If true, do not validate the manifest.
"""

no_validate: Optional[bool] = None


class WrapManifestVersions(Enum):
"""The versions of the Wrap manifest."""

Expand Down Expand Up @@ -68,3 +57,24 @@ class WrapAbiVersions(Enum):

LATEST_WRAP_MANIFEST_VERSION = "0.1"
LATEST_WRAP_ABI_VERSION = "0.1"

__all__ = [
# Options
"DeserializeManifestOptions",
# Enums
"WrapManifestVersions",
"WrapManifestAbiVersions",
"WrapAbiVersions",
# Concrete Versions
"WrapManifest_0_1",
"WrapAbi_0_1_0_1",
# Any Versions
"AnyWrapManifest",
"AnyWrapAbi",
# Latest Versions
"WrapManifest",
"WrapAbi",
# Latest Version constants
"LATEST_WRAP_MANIFEST_VERSION",
"LATEST_WRAP_ABI_VERSION",
]
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