Skip to content

Commit

Permalink
files updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviksaikat committed May 30, 2024
1 parent a17826a commit a387d35
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ ENV/
.DS_Store
.vscode/

# pdm
# pdm
.pdm-python

# ruff
.ruff_cache/*
.ruff_cache/
_verion.py
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ include = [
"tests/**/*.py",
"tests/**/*.pyi"
]
exclude = ["tests", "src/mantaray_py/_version.py"]

[tool.ruff.lint]
preview = true # preview features & checks, use with caution
Expand Down Expand Up @@ -177,9 +178,10 @@ post-install-commands = ["pre-commit install"]
# Lint env dendencies
[tool.hatch.envs.lint]
dependencies = [
"pydantic",
"mypy",
"ruff",
"deptry",
"deptry",
]


Expand Down Expand Up @@ -227,8 +229,7 @@ build-check = [
[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",

"pytest-cov",
]


Expand All @@ -255,4 +256,4 @@ exclude = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/mantaray_py/"]
packages = ["src/mantaray_py/"]
4 changes: 2 additions & 2 deletions src/mantaray_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("mantaray-py")
__version__ = version('mantaray-py')
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"
__version__ = 'unknown'
finally:
del version, PackageNotFoundError
17 changes: 17 additions & 0 deletions src/mantaray_py/_version.py
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')
51 changes: 51 additions & 0 deletions src/mantaray_py/types/types.py
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
3 changes: 2 additions & 1 deletion tests/test_add.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest

from mantaray_py import add


@pytest.mark.parametrize(
"a,b,result",
'a,b,result',
[
(0, 0, 0),
(1, 1, 2),
Expand Down

0 comments on commit a387d35

Please sign in to comment.