tsrkit-types 0.1.6__py3-none-any.whl → 0.1.8__py3-none-any.whl

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/bytearray.py CHANGED
@@ -28,10 +28,12 @@ class ByteArray(bytearray, Codable, BytesMixin):
28
28
  current_offset = offset
29
29
  _len, _inc_offset = Uint.decode_from(buffer, offset)
30
30
  current_offset += _inc_offset
31
+ if len(buffer[current_offset:current_offset+_len]) < _len:
32
+ raise TypeError("Insufficient buffer")
31
33
  return cls(buffer[current_offset:current_offset+_len]), current_offset + _len - offset
32
34
 
33
35
  # ---------------------------------------------------------------------------- #
34
36
  # JSON Serialization #
35
37
  # ---------------------------------------------------------------------------- #
36
38
  # JSON methods inherited from BytesMixin
37
-
39
+
tsrkit_types/bytes.py CHANGED
@@ -51,9 +51,13 @@ class Bytes(bytes, Codable, BytesMixin, metaclass=BytesCheckMeta):
51
51
  def decode_from(cls, buffer: Union[bytes, bytearray, memoryview], offset: int = 0) -> Tuple["Bytes", int]:
52
52
  current_offset = offset
53
53
  _len = cls._length
54
+
54
55
  if _len is None:
55
56
  _len, _inc_offset = Uint.decode_from(buffer, offset)
56
57
  current_offset += _inc_offset
58
+
59
+ if len(buffer[current_offset:current_offset+_len]) < _len:
60
+ raise TypeError("Insufficient buffer")
57
61
  return cls(buffer[current_offset:current_offset+_len]), current_offset + _len - offset
58
62
 
59
63
  # ---------------------------------------------------------------------------- #
@@ -67,4 +71,4 @@ Bytes64 = Bytes[64]
67
71
  Bytes128 = Bytes[128]
68
72
  Bytes256 = Bytes[256]
69
73
  Bytes512 = Bytes[512]
70
- Bytes1024 = Bytes[1024]
74
+ Bytes1024 = Bytes[1024]
tsrkit_types/integers.py CHANGED
@@ -80,11 +80,11 @@ class Int(int, Codable, metaclass=IntCheckMeta):
80
80
  def __new__(cls, value: Any):
81
81
  value = int(value)
82
82
  if cls.byte_size > 0:
83
- max_v = cls._bound // 2 if cls.signed else cls._bound
83
+ max_v = (cls._bound // 2 if cls.signed else cls._bound) - 1
84
84
  min_v = -1 * cls._bound // 2 if cls.signed else 0
85
85
  else:
86
86
  min_v = -1 * cls._bound // 2 if cls.signed else 0
87
- max_v = cls._bound // 2 if cls.signed else cls._bound - 1
87
+ max_v = (cls._bound // 2 if cls.signed else cls._bound) - 1
88
88
 
89
89
  if not (min_v <= value <= max_v):
90
90
  raise ValueError(f"Int: {cls.__name__} out of range: {value!r} "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tsrkit-types
3
- Version: 0.1.6
3
+ Version: 0.1.8
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
@@ -794,6 +794,20 @@ pytest -v
794
794
  pytest -m "not slow"
795
795
  ```
796
796
 
797
+ ### Build and Publish
798
+
799
+ 1. Build the package:
800
+
801
+ ```bash
802
+ python3 -m build --wheel
803
+ ```
804
+
805
+ 2. Publish the wheels:
806
+
807
+ ```bash
808
+ twine upload dist/*
809
+ ```
810
+
797
811
  ### Test Coverage
798
812
 
799
813
  View the test coverage report:
@@ -1,21 +1,21 @@
1
1
  tsrkit_types/__init__.py,sha256=PlhqxNwjXaJU5vTIqJdLvC5BBfExLAoKQ57peNG2Opc,1900
2
2
  tsrkit_types/bits.py,sha256=33WLfuUYdzGscoc-E3InTYdbJRIDeixoe_pG0XAv71c,4213
3
3
  tsrkit_types/bool.py,sha256=Veu6KLIeiRFnIW1sbawJ0haF0veyaL-As5mBiypq-uE,1280
4
- tsrkit_types/bytearray.py,sha256=DaMnACq-7pzEW-pRO2f_IAny_8ldhSt3G5D24Soywk4,1662
5
- tsrkit_types/bytes.py,sha256=V_sFmpOsftGb3IPXqExOlDHbt4CpJWM6md-kQ3_CEmg,2734
4
+ tsrkit_types/bytearray.py,sha256=5uBK_5bHVxRAocfRHDojCTtS2ysUh-8bFdWglO-ZM48,1781
5
+ tsrkit_types/bytes.py,sha256=tsyeItlI4LZPnkxFY-5_kgoDs04Zk_Xuan1erkG4Ff0,2863
6
6
  tsrkit_types/bytes_common.py,sha256=b1Zqh_NhkCX718QaZC52J3nEzKAi1Fe8E0nefWVwwmo,2301
7
7
  tsrkit_types/choice.py,sha256=OVHxIr2PcnaTpo5sAMjipCArc5oATNsyYkqZNRqU7bA,5253
8
8
  tsrkit_types/dictionary.py,sha256=GcUvaHC1VOEc3OzUVAH0id--ncLqTJ6ZRz-lucMNRdY,5618
9
9
  tsrkit_types/enum.py,sha256=3MyLW15_ToQQdctJjcMY8Xb3OsS_Ad997OOEo8FjVeA,4256
10
- tsrkit_types/integers.py,sha256=OARdkz7j06xCU2AZz4_RciR1hVexSnF1tAQ3HQGNZI8,8858
10
+ tsrkit_types/integers.py,sha256=Xu9hjGQWW_NP08QIhKSvlxTeA3UmKsQC1A3NatgILQo,8867
11
11
  tsrkit_types/null.py,sha256=vzobz4-xJrUeky8pzbg-Qmz4N6b7GsCNf8TafbstlgY,1372
12
12
  tsrkit_types/option.py,sha256=xwtaAFN20GjaGqzYZAAo1fZqqUZnCYHdy2bjshhY620,1631
13
13
  tsrkit_types/sequences.py,sha256=KOT5-4mia5Lc0CMjIF7Yqe34Sei92ZQ2s6GaP13soUg,8090
14
14
  tsrkit_types/string.py,sha256=8rvg0BwvyhQnbMW3qornmBFTQHeTQFUfwD7OC0eVgcY,2575
15
15
  tsrkit_types/struct.py,sha256=GoXWFc1OqO9CXnxFS7Xkms7J-rtZe8h32LkAIBlzdSM,3497
16
16
  tsrkit_types/itf/codable.py,sha256=agx8YSVWGBeEiLrU9eqh3ZoeTgpJsmmIlW622xIKqPI,2810
17
- tsrkit_types-0.1.6.dist-info/licenses/LICENSE,sha256=TwnDvVCPwHadHWLUuY1sPx03XNw1jzh_ZmoDBNai9Uc,1072
18
- tsrkit_types-0.1.6.dist-info/METADATA,sha256=JLEqIyXYIju0AqWihQakM593qyyKNvdMjuTCVo9CKBI,22755
19
- tsrkit_types-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- tsrkit_types-0.1.6.dist-info/top_level.txt,sha256=pnVhnUsnZ_A0FIj1zHwDw3suMGrfMJwusp-4GPVY1CM,13
21
- tsrkit_types-0.1.6.dist-info/RECORD,,
17
+ tsrkit_types-0.1.8.dist-info/licenses/LICENSE,sha256=TwnDvVCPwHadHWLUuY1sPx03XNw1jzh_ZmoDBNai9Uc,1072
18
+ tsrkit_types-0.1.8.dist-info/METADATA,sha256=XcMJiwod5CkNHpwSSrMTOvRZxMMpv9FEDhi_AS7IYPU,22896
19
+ tsrkit_types-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ tsrkit_types-0.1.8.dist-info/top_level.txt,sha256=pnVhnUsnZ_A0FIj1zHwDw3suMGrfMJwusp-4GPVY1CM,13
21
+ tsrkit_types-0.1.8.dist-info/RECORD,,