tsrkit-types 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/CHANGELOG.md +1 -1
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/PKG-INFO +3 -4
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/README.md +1 -1
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/pyproject.toml +2 -3
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/bytes.py +3 -5
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/enum.py +3 -3
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/null.py +3 -3
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/sequences.py +1 -1
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types.egg-info/PKG-INFO +3 -4
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/CONTRIBUTING.md +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/LICENSE +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/MANIFEST.in +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/pytest.ini +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/setup.cfg +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/setup.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_bytes.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_choices.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_containers.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_enums.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_int.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_integers.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_network.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_seq.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_strings.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_struct.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tests/test_structs.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/__init__.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/bits.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/bool.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/choice.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/dictionary.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/integers.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/itf/codable.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/option.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/string.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types/struct.py +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types.egg-info/SOURCES.txt +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types.egg-info/dependency_links.txt +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types.egg-info/requires.txt +0 -0
- {tsrkit_types-0.1.1 → tsrkit_types-0.1.2}/tsrkit_types.egg-info/top_level.txt +0 -0
|
@@ -35,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
35
35
|
- Type validation at construction and assignment time
|
|
36
36
|
- Support for nested and complex type compositions
|
|
37
37
|
- Zero-dependency core library
|
|
38
|
-
- Python 3.
|
|
38
|
+
- Python 3.11+ support
|
|
39
39
|
|
|
40
40
|
## [Unreleased]
|
|
41
41
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tsrkit-types
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies
|
|
5
5
|
Author-email: chainscore-labs <hello@chainscore.finance>, prasad-kumkar <prasad@chainscore.finance>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,6 @@ Classifier: Intended Audience :: Developers
|
|
|
15
15
|
Classifier: Intended Audience :: System Administrators
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
@@ -28,7 +27,7 @@ Classifier: Topic :: Utilities
|
|
|
28
27
|
Classifier: Topic :: System :: Archiving
|
|
29
28
|
Classifier: Topic :: Communications
|
|
30
29
|
Classifier: Typing :: Typed
|
|
31
|
-
Requires-Python: >=3.
|
|
30
|
+
Requires-Python: >=3.11
|
|
32
31
|
Description-Content-Type: text/markdown
|
|
33
32
|
License-File: LICENSE
|
|
34
33
|
Provides-Extra: dev
|
|
@@ -735,6 +734,6 @@ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for gui
|
|
|
735
734
|
|
|
736
735
|
## Requirements
|
|
737
736
|
|
|
738
|
-
- **Python**: >= 3.
|
|
737
|
+
- **Python**: >= 3.11
|
|
739
738
|
- **Runtime Dependencies**: None (zero dependencies!)
|
|
740
739
|
- **Development Dependencies**: pytest and plugins (see `pyproject.toml`)
|
|
@@ -693,6 +693,6 @@ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for gui
|
|
|
693
693
|
|
|
694
694
|
## Requirements
|
|
695
695
|
|
|
696
|
-
- **Python**: >= 3.
|
|
696
|
+
- **Python**: >= 3.11
|
|
697
697
|
- **Runtime Dependencies**: None (zero dependencies!)
|
|
698
698
|
- **Development Dependencies**: pytest and plugins (see `pyproject.toml`)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tsrkit-types"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
description = "Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "chainscore-labs", email = "hello@chainscore.finance"},
|
|
@@ -8,7 +8,7 @@ authors = [
|
|
|
8
8
|
]
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
12
|
keywords = [
|
|
13
13
|
"serialization", "binary", "encoding", "types", "codable", "json",
|
|
14
14
|
"validation", "data-types", "type-safety", "zero-copy", "protocol",
|
|
@@ -20,7 +20,6 @@ classifiers = [
|
|
|
20
20
|
"Intended Audience :: System Administrators",
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
22
|
"Programming Language :: Python :: 3",
|
|
23
|
-
"Programming Language :: Python :: 3.10",
|
|
24
23
|
"Programming Language :: Python :: 3.11",
|
|
25
24
|
"Programming Language :: Python :: 3.12",
|
|
26
25
|
"Programming Language :: Python :: 3 :: Only",
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from typing import Tuple, Union, ClassVar
|
|
2
|
-
import base64
|
|
3
|
-
|
|
1
|
+
from typing import Tuple, Union, ClassVar
|
|
4
2
|
from tsrkit_types.integers import Uint
|
|
5
3
|
from tsrkit_types.itf.codable import Codable
|
|
6
4
|
|
|
@@ -22,7 +20,7 @@ class Bytes(bytes, Codable):
|
|
|
22
20
|
return f"{self.__class__.__name__}({self.hex()})"
|
|
23
21
|
|
|
24
22
|
@classmethod
|
|
25
|
-
def from_bits(cls, bits: list[bool], bit_order = "msb") ->
|
|
23
|
+
def from_bits(cls, bits: list[bool], bit_order = "msb") -> "Bytes":
|
|
26
24
|
# Sanitize input: make sure bits are 0 or 1
|
|
27
25
|
bits = [int(bool(b)) for b in bits]
|
|
28
26
|
n = len(bits)
|
|
@@ -79,7 +77,7 @@ class Bytes(bytes, Codable):
|
|
|
79
77
|
return current_offset - offset
|
|
80
78
|
|
|
81
79
|
@classmethod
|
|
82
|
-
def decode_from(cls, buffer: Union[bytes, bytearray, memoryview], offset: int = 0) -> Tuple[
|
|
80
|
+
def decode_from(cls, buffer: Union[bytes, bytearray, memoryview], offset: int = 0) -> Tuple["Bytes", int]:
|
|
83
81
|
current_offset = offset
|
|
84
82
|
_len = cls._length
|
|
85
83
|
if _len is None:
|
|
@@ -20,8 +20,8 @@ class Enum(metaclass=EnumMeta):
|
|
|
20
20
|
>>> assert decoded == value
|
|
21
21
|
>>> assert bytes_read == 1
|
|
22
22
|
>>>
|
|
23
|
-
>>> assert MyEnum.from_json(1
|
|
24
|
-
>>> assert MyEnum.from_json("A"
|
|
23
|
+
>>> assert MyEnum.from_json(1) == MyEnum.A
|
|
24
|
+
>>> assert MyEnum.from_json("A") == MyEnum.A
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
@property
|
|
@@ -106,7 +106,7 @@ class Enum(metaclass=EnumMeta):
|
|
|
106
106
|
The corresponding enum value
|
|
107
107
|
|
|
108
108
|
Raises:
|
|
109
|
-
|
|
109
|
+
ValueError: If the value is invalid
|
|
110
110
|
"""
|
|
111
111
|
for v in cls.__members__.values():
|
|
112
112
|
if v._value_ == data or v._name_ == data:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional,
|
|
1
|
+
from typing import Optional, Tuple, Union
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class NullType:
|
|
@@ -22,7 +22,7 @@ class NullType:
|
|
|
22
22
|
return 0
|
|
23
23
|
|
|
24
24
|
@classmethod
|
|
25
|
-
def decode_from(cls, buffer: Union[bytes, bytearray, memoryview], offset: int = 0) -> Tuple[
|
|
25
|
+
def decode_from(cls, buffer: Union[bytes, bytearray, memoryview], offset: int = 0) -> Tuple['NullType', int]:
|
|
26
26
|
return cls(), 0
|
|
27
27
|
|
|
28
28
|
# ---------------------------------------------------------------------------- #
|
|
@@ -33,7 +33,7 @@ class NullType:
|
|
|
33
33
|
return None
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
|
-
def from_json(cls, json_str: Optional[str]) ->
|
|
36
|
+
def from_json(cls, json_str: Optional[str]) -> 'NullType':
|
|
37
37
|
if json_str is None:
|
|
38
38
|
return cls()
|
|
39
39
|
raise ValueError("Invalid JSON string for NullType")
|
|
@@ -84,7 +84,7 @@ class Seq(list, Codable, Generic[T], metaclass=SeqCheckMeta):
|
|
|
84
84
|
raise TypeError(f"{value!r} is not an instance of {self._element_type!r}")
|
|
85
85
|
|
|
86
86
|
def _validate_self(self):
|
|
87
|
-
"""For Resultant
|
|
87
|
+
"""For Resultant self check - added to fns that alter size"""
|
|
88
88
|
if len(self) < self._min_length:
|
|
89
89
|
raise ValueError(f"Vector: Expected sequence size to be >= {self._min_length}, resultant size {len(self)}")
|
|
90
90
|
elif len(self) > self._max_length:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tsrkit-types
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies
|
|
5
5
|
Author-email: chainscore-labs <hello@chainscore.finance>, prasad-kumkar <prasad@chainscore.finance>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,6 @@ Classifier: Intended Audience :: Developers
|
|
|
15
15
|
Classifier: Intended Audience :: System Administrators
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
@@ -28,7 +27,7 @@ Classifier: Topic :: Utilities
|
|
|
28
27
|
Classifier: Topic :: System :: Archiving
|
|
29
28
|
Classifier: Topic :: Communications
|
|
30
29
|
Classifier: Typing :: Typed
|
|
31
|
-
Requires-Python: >=3.
|
|
30
|
+
Requires-Python: >=3.11
|
|
32
31
|
Description-Content-Type: text/markdown
|
|
33
32
|
License-File: LICENSE
|
|
34
33
|
Provides-Extra: dev
|
|
@@ -735,6 +734,6 @@ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for gui
|
|
|
735
734
|
|
|
736
735
|
## Requirements
|
|
737
736
|
|
|
738
|
-
- **Python**: >= 3.
|
|
737
|
+
- **Python**: >= 3.11
|
|
739
738
|
- **Runtime Dependencies**: None (zero dependencies!)
|
|
740
739
|
- **Development Dependencies**: pytest and plugins (see `pyproject.toml`)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|