osbot-utils 2.74.0__py3-none-any.whl → 2.75.0__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.
@@ -2,7 +2,7 @@ import re
2
2
  from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
3
3
 
4
4
  TYPE_SAFE_STR__TEXT__MAX_LENGTH = 4096
5
- TYPE_SAFE_STR__TEXT__REGEX = r'[^a-zA-Z0-9_ ()\[\]\-+=:;,.?]'
5
+ TYPE_SAFE_STR__TEXT__REGEX = r'[^a-zA-Z0-9_ ()\[\]\-+=:;,.?*]'
6
6
 
7
7
  class Safe_Str__Text(Safe_Str):
8
8
  regex = re.compile(TYPE_SAFE_STR__TEXT__REGEX)
@@ -1,5 +1,8 @@
1
- from typing import Type
2
- from osbot_utils.type_safe.Type_Safe__Base import Type_Safe__Base, type_str
1
+ from typing import Type
2
+ from osbot_utils.type_safe.Type_Safe__Primitive import Type_Safe__Primitive
3
+ from osbot_utils.type_safe.Type_Safe__Base import Type_Safe__Base, type_str
4
+
5
+
3
6
 
4
7
  class Type_Safe__List(Type_Safe__Base, list):
5
8
  expected_type : Type
@@ -16,14 +19,27 @@ class Type_Safe__List(Type_Safe__Base, list):
16
19
  def __exit__ (self, type, value, traceback): pass
17
20
 
18
21
  def append(self, item):
19
- from osbot_utils.type_safe.Type_Safe import Type_Safe
20
- if type(self.expected_type) is type and issubclass(self.expected_type, Type_Safe) and type(item) is dict: # if self.expected_type is Type_Safe and we have a dict
21
- item = self.expected_type.from_json(item) # try to convert the dict into self.expected_type
22
- else:
23
- try:
24
- self.is_instance_of_type(item, self.expected_type)
25
- except TypeError as e:
26
- raise TypeError(f"In Type_Safe__List: Invalid type for item: {e}") from None
22
+ from osbot_utils.type_safe.Type_Safe import Type_Safe # to prevent circular imports
23
+
24
+ # Handle Type_Safe objects from dicts
25
+ if type(self.expected_type) is type and issubclass(self.expected_type, Type_Safe) and type(item) is dict:
26
+ item = self.expected_type.from_json(item)
27
+ # Handle Type_Safe__Primitive conversions (str -> Safe_Str, etc.)
28
+ elif type(self.expected_type) is type and issubclass(self.expected_type, Type_Safe__Primitive):
29
+ if not isinstance(item, self.expected_type):
30
+ try:
31
+ item = self.expected_type(item)
32
+ except (ValueError, TypeError) as e:
33
+ # Re-raise with more context about what failed
34
+ raise TypeError(f"In Type_Safe__List: Could not convert {type(item).__name__} to {self.expected_type.__name__}: {e}") from None
35
+
36
+
37
+ # Now validate the (possibly converted) item
38
+ try:
39
+ self.is_instance_of_type(item, self.expected_type)
40
+ except TypeError as e:
41
+ raise TypeError(f"In Type_Safe__List: Invalid type for item: {e}") from None
42
+
27
43
  super().append(item)
28
44
 
29
45
 
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.74.0
1
+ v2.75.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.74.0
3
+ Version: 2.75.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  License: MIT
6
6
  Author: Dinis Cruz
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
21
21
 
22
22
  # OSBot-Utils
23
23
 
24
- ![Current Release](https://img.shields.io/badge/release-v2.74.0-blue)
24
+ ![Current Release](https://img.shields.io/badge/release-v2.75.0-blue)
25
25
  ![Python](https://img.shields.io/badge/python-3.8+-green)
26
26
  ![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)
27
27
  ![Caching](https://img.shields.io/badge/Caching-Built--In-orange)
@@ -389,7 +389,7 @@ osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid.py,sha256=86xn
389
389
  osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid_Short.py,sha256=YP_k5OLuYvXWGU2OEnQHk_OGViBQofTWKm3pUdQaJao,404
390
390
  osbot_utils/type_safe/primitives/safe_str/identifiers/Safe_Id.py,sha256=Mj66QVcEHqUKDFb0cdl7cbMOlQKxfFuRxnupmKo6UG8,696
391
391
  osbot_utils/type_safe/primitives/safe_str/identifiers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
392
- osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text.py,sha256=0oyn8xs8mabFkzyOdn_HV6UYsH7oHHNrmWM4z3TKwMU,326
392
+ osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text.py,sha256=95E4ALhah2AEfL-m5JB7XpUOkyxQ0lJQM139RPQJjv4,327
393
393
  osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text__Dangerous.py,sha256=WrEvoXeHWuevzgbfUkm2xisGUMIlDS39Nte3P2_hyHg,401
394
394
  osbot_utils/type_safe/primitives/safe_str/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
395
395
  osbot_utils/type_safe/primitives/safe_str/web/Safe_Str__Html.py,sha256=HnCnKUBPB0IfEXSoeK4XFB08qjnAaOYyd-s1smvI2pQ,675
@@ -404,7 +404,7 @@ osbot_utils/type_safe/primitives/safe_uint/Safe_UInt__Port.py,sha256=gcqi3UaWaFN
404
404
  osbot_utils/type_safe/primitives/safe_uint/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
405
405
  osbot_utils/type_safe/type_safe_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
406
406
  osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Dict.py,sha256=TYb1nXbVqn4bGoagGqr4U__LofpjDllKxiVJCL705PI,3159
407
- osbot_utils/type_safe/type_safe_core/collections/Type_Safe__List.py,sha256=y_lp7Ai0HfQCqC8Bxn0g6_M9MP5lPOXy5Dhkuj2fJvQ,1891
407
+ osbot_utils/type_safe/type_safe_core/collections/Type_Safe__List.py,sha256=VYlTzDXnreb5s6Ue5AIq-ehxg3jHppOVES0CppjhCsg,2607
408
408
  osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Set.py,sha256=j12fc8cbd9-s_a13ysaz723rNEW4Dt6hObCd0S-AjIg,1432
409
409
  osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Tuple.py,sha256=Kx7C4YfHybRbMmVMcmV6yFLi4T48pb592vEZfjjyLxo,1710
410
410
  osbot_utils/type_safe/type_safe_core/collections/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -462,8 +462,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
462
462
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
463
463
  osbot_utils/utils/Zip.py,sha256=mG42lgTY0tnm14T3P1-DSAIZKkTiYoO3odZ1aOUdc1I,14394
464
464
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
465
- osbot_utils/version,sha256=Hh7DgaX3ZQajaSIvFEOMRoqJXUw_aeyoA1gzj_OJSZk,8
466
- osbot_utils-2.74.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
467
- osbot_utils-2.74.0.dist-info/METADATA,sha256=6sQ5TtiuRR_virvWkZC5xrr8_aXuas-pO4YMF5wwdlA,7905
468
- osbot_utils-2.74.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
469
- osbot_utils-2.74.0.dist-info/RECORD,,
465
+ osbot_utils/version,sha256=2dprv-TzJozAbapaMttCQT1_wv77Mq1Y8gfR1PL_D-k,8
466
+ osbot_utils-2.75.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
467
+ osbot_utils-2.75.0.dist-info/METADATA,sha256=2R9-5Mc5oJK7MyrexskI17QkHoyrfefEWycnJUJozqs,7905
468
+ osbot_utils-2.75.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
469
+ osbot_utils-2.75.0.dist-info/RECORD,,