-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a17826a
commit a387d35
Showing
6 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,8 +108,9 @@ ENV/ | |
.DS_Store | ||
.vscode/ | ||
|
||
# pdm | ||
# pdm | ||
.pdm-python | ||
|
||
# ruff | ||
.ruff_cache/* | ||
.ruff_cache/ | ||
_verion.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# file generated by setuptools_scm | ||
# don't change, don't track in version control | ||
TYPE_CHECKING = False | ||
if TYPE_CHECKING: | ||
from typing import Tuple, Union | ||
|
||
VERSION_TUPLE = Tuple[Union[int, str], ...] | ||
else: | ||
VERSION_TUPLE = object | ||
|
||
version: str | ||
__version__: str | ||
__version_tuple__: VERSION_TUPLE | ||
version_tuple: VERSION_TUPLE | ||
|
||
__version__ = version = '0.0.post1.dev1+ga17826a' | ||
__version_tuple__ = version_tuple = (0, 0, 'dev1', 'ga17826a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Callable, Literal, Optional, Union | ||
|
||
from pydantic import BaseModel, conlist | ||
|
||
# Equivalent to the 'marshal_versionValues' and 'marshal_version' in TypeScript | ||
marshal_version_values = ('0.1', '0.2') | ||
marshal_version = Literal['0.1', '0.2'] | ||
|
||
|
||
# Equivalent to the 'NodeType' enum in TypeScript | ||
class NodeType: | ||
value = 2 | ||
edge = 4 | ||
with_path_separator = 8 | ||
with_metadata = 16 | ||
mask = 255 | ||
|
||
|
||
# Custom type for Bytes with constrained length | ||
def create_bytes_type(length: int): | ||
return conlist(int, min_items=length, max_items=length) | ||
|
||
|
||
Bytes32 = create_bytes_type(32) | ||
Bytes64 = create_bytes_type(64) | ||
Reference = Union[Bytes32, Bytes64] | ||
|
||
|
||
# Equivalent to the 'metadata_mapping' type in TypeScript | ||
metadata_mapping = dict[str, str] | ||
|
||
# Equivalent to the 'Storage_loader' and 'StorageSaver' in TypeScript | ||
Storage_loader = Callable[[Reference], bytes] | ||
Storage_saver = Callable[[bytes, Optional[dict]], Reference] | ||
|
||
|
||
# Equivalent to the 'StorageHandler' type in TypeScript | ||
class StorageHandler(BaseModel): | ||
load: Storage_loader | ||
save: Storage_saver | ||
|
||
|
||
# Example usage of the defined models and types | ||
class ExampleUsage(BaseModel): | ||
version: marshal_version | ||
reference: Reference | ||
metadata: metadata_mapping | ||
handler: StorageHandler | ||
|
||
class Config: | ||
arbitrary_types_allowed = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters