osbot-utils 2.77.0__py3-none-any.whl → 2.78.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.
- osbot_utils/type_safe/type_safe_core/methods/Type_Safe__Method.py +25 -6
- osbot_utils/version +1 -1
- {osbot_utils-2.77.0.dist-info → osbot_utils-2.78.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.77.0.dist-info → osbot_utils-2.78.0.dist-info}/RECORD +6 -6
- {osbot_utils-2.77.0.dist-info → osbot_utils-2.78.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.77.0.dist-info → osbot_utils-2.78.0.dist-info}/WHEEL +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import collections
|
1
2
|
import inspect # For function introspection
|
2
3
|
from enum import Enum
|
3
4
|
from typing import get_args, get_origin, Union, List, Any, Dict # For type hinting utilities
|
@@ -105,14 +106,32 @@ class Type_Safe__Method:
|
|
105
106
|
if not isinstance(param_value, list): # Check if value is a list
|
106
107
|
raise ValueError(f"Parameter '{param_name}' expected a list but got {type(param_value)}") # Raise error if not list
|
107
108
|
|
108
|
-
item_type = get_args(expected_type)[0]
|
109
|
-
|
109
|
+
item_type = get_args(expected_type)[0] # Get list item type
|
110
|
+
item_origin = get_origin(item_type) # Get origin of item type
|
111
|
+
|
112
|
+
if item_origin is dict or item_origin is Dict: # Handle Dict[K, V] items
|
113
|
+
key_type, value_type = get_args(item_type) # Extract key and value types
|
114
|
+
for i, item in enumerate(param_value): # Validate each dict in list
|
115
|
+
if not isinstance(item, dict): # Check item is a dict
|
116
|
+
raise ValueError(f"List item at index {i} expected dict but got {type(item)}") # Raise error if not dict
|
117
|
+
for k, v in item.items(): # Validate dict contents
|
118
|
+
if not isinstance(k, key_type): # Check key type
|
119
|
+
raise ValueError(f"Dict key '{k}' at index {i} expected type {key_type}, but got {type(k)}") # Raise error for invalid key
|
120
|
+
if not isinstance(v, value_type): # Check value type
|
121
|
+
raise ValueError(f"Dict value for key '{k}' at index {i} expected type {value_type}, but got {type(v)}") # Raise error for invalid value
|
122
|
+
elif item_origin is collections.abc.Callable: # Handle Callable[[...], ...] items
|
123
|
+
for i, item in enumerate(param_value): # Validate each callable in list
|
124
|
+
if not callable(item): # Check item is callable
|
125
|
+
raise ValueError(f"List item at index {i} expected callable but got {type(item)}") # Raise error if not callable
|
126
|
+
# Note: Full signature validation would require is_callable_compatible method
|
127
|
+
elif item_origin is not None: # Handle other subscripted types
|
110
128
|
raise NotImplementedError(f"Validation for list items with subscripted type"
|
111
129
|
f" '{item_type}' is not yet supported "
|
112
|
-
f"in parameter '{param_name}'.")
|
113
|
-
|
114
|
-
|
115
|
-
|
130
|
+
f"in parameter '{param_name}'.") # todo: add support for checking for subscripted types
|
131
|
+
else: # Handle non-subscripted types
|
132
|
+
for i, item in enumerate(param_value): # Check each list item
|
133
|
+
if not isinstance(item, item_type): # Validate item type
|
134
|
+
raise ValueError(f"List item at index {i} expected type {item_type}, but got {type(item)}") # Raise error for invalid item
|
116
135
|
|
117
136
|
def validate_type_parameter(self, param_name: str, param_value: Any, expected_type: Any): # Validate a Type[T] parameter
|
118
137
|
if not isinstance(param_value, type):
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.
|
1
|
+
v2.78.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.78.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
|
-

|
25
25
|

|
26
26
|

|
27
27
|

|
@@ -416,7 +416,7 @@ osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Tuple.py,sha256=Kx7C
|
|
416
416
|
osbot_utils/type_safe/type_safe_core/collections/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
417
417
|
osbot_utils/type_safe/type_safe_core/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
418
418
|
osbot_utils/type_safe/type_safe_core/decorators/type_safe.py,sha256=wOTMvZBl5hWMz-HuIRZpPBGN0oSbXWd9wH5xxZkfLlA,1796
|
419
|
-
osbot_utils/type_safe/type_safe_core/methods/Type_Safe__Method.py,sha256
|
419
|
+
osbot_utils/type_safe/type_safe_core/methods/Type_Safe__Method.py,sha256=-EHM5goVg-CvVufeMFi_jUSTldpla4FQiq6XO5ZJtUs,18776
|
420
420
|
osbot_utils/type_safe/type_safe_core/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
421
421
|
osbot_utils/type_safe/type_safe_core/methods/type_safe_property.py,sha256=DcJkOIs6swJtkglsZVKLyFSczCGSJISOVwAmvjCOQvo,1425
|
422
422
|
osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Annotations.py,sha256=kabSiRPYPjpMBJxfjDB5AFRTx-hX17tOznZAd_qQID4,1147
|
@@ -468,8 +468,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
|
|
468
468
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
469
469
|
osbot_utils/utils/Zip.py,sha256=mG42lgTY0tnm14T3P1-DSAIZKkTiYoO3odZ1aOUdc1I,14394
|
470
470
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
471
|
-
osbot_utils/version,sha256=
|
472
|
-
osbot_utils-2.
|
473
|
-
osbot_utils-2.
|
474
|
-
osbot_utils-2.
|
475
|
-
osbot_utils-2.
|
471
|
+
osbot_utils/version,sha256=FLt36i-Z9JlSrMuWB_X-ax-Q6m5iqCavlXxD3VyyqsY,8
|
472
|
+
osbot_utils-2.78.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
473
|
+
osbot_utils-2.78.0.dist-info/METADATA,sha256=eCXicYRH0eHxjGxH6YOcx4ivHlHr2x70aoYujqC_wPs,7918
|
474
|
+
osbot_utils-2.78.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
475
|
+
osbot_utils-2.78.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|