Skip to content

Commit

Permalink
Implemented support for pickle
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
sg495 committed Dec 18, 2023
1 parent 41f4ece commit 48a40f2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"esbonio.sphinx.confDir": "${workspaceFolder}\\docs",
"workbench.colorTheme": "Default Dark+"
"workbench.colorTheme": "Default Dark Modern"
}
3 changes: 3 additions & 0 deletions multiformats/cid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def __new__(cls: Type[_CIDSubclass],
return CID._new_instance(cls, base, version, codec, hashfun, digest)
return CID._new_instance(cls, base, version, codec, hashfun, (hashfun, raw_digest))

def __getnewargs__(self) -> tuple[Multibase, CIDVersion, Multicodec, bytes]:
return self.base, self.version, self.codec, self.digest

@staticmethod
def _new_instance(CID_subclass: Type[_CIDSubclass],
base: Multibase,
Expand Down
3 changes: 3 additions & 0 deletions multiformats/multiaddr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def __new__(cls, codec: Union[str, int, Multicodec]) -> "Proto":
_cache[codec.name] = instance
return instance

def __getnewargs__(self) -> tuple[Multicodec]:
return (self.codec,)

@property
def name(self) -> str:
"""
Expand Down
3 changes: 3 additions & 0 deletions multiformats/multibase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def __new__(cls,
instance._description = description
return instance

def __getnewargs__(self) -> tuple[str, str, MultibaseStatus, str]:
return (self.name, self.code, self.status, self.description)

@staticmethod
def _validate_name(name: Optional[str]) -> str:
validate(name, Optional[str])
Expand Down
3 changes: 3 additions & 0 deletions multiformats/multicodec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def __new__(cls,
instance._description = description
return instance

def __getnewargs__(self) -> tuple[str, str, int, MulticodecStatus, str]:
return (self.name, self.tag, self.code, self.status, self.description)

@staticmethod
def _validate_name(name: str) -> str:
if not re.match(r"^[a-z][a-z0-9_-]+$", name):
Expand Down
3 changes: 3 additions & 0 deletions multiformats/multihash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def __new__(cls, codec: Union[str, int, Multicodec]) -> "Multihash":
_cache[codec.name] = instance
return instance

def __getnewargs__(self) -> tuple[Multicodec]:
return (self.codec,)

@property
def name(self) -> str:
"""
Expand Down

0 comments on commit 48a40f2

Please sign in to comment.