osbot-utils 1.85.0__py3-none-any.whl → 1.87.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/helpers/Type_Safe_Method.py +20 -13
- osbot_utils/utils/Objects.py +1 -0
- osbot_utils/version +1 -1
- {osbot_utils-1.85.0.dist-info → osbot_utils-1.87.0.dist-info}/METADATA +2 -2
- {osbot_utils-1.85.0.dist-info → osbot_utils-1.87.0.dist-info}/RECORD +7 -7
- {osbot_utils-1.85.0.dist-info → osbot_utils-1.87.0.dist-info}/LICENSE +0 -0
- {osbot_utils-1.85.0.dist-info → osbot_utils-1.87.0.dist-info}/WHEEL +0 -0
@@ -1,5 +1,6 @@
|
|
1
|
-
import inspect
|
2
|
-
from
|
1
|
+
import inspect # For function introspection
|
2
|
+
from enum import Enum
|
3
|
+
from typing import get_args, get_origin, Optional, Union, List, Any, Dict # For type hinting utilities
|
3
4
|
|
4
5
|
|
5
6
|
class Type_Safe_Method: # Class to handle method type safety validation
|
@@ -86,17 +87,23 @@ class Type_Safe_Method:
|
|
86
87
|
if not any(isinstance(param_value, arg_type) for arg_type in args_types): # Check if value matches any type
|
87
88
|
raise ValueError(f"Parameter '{param_name}' expected one of types {args_types}, but got {type(param_value)}") # Raise error if no match
|
88
89
|
|
89
|
-
def try_basic_type_conversion(self, param_value: Any,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
90
|
+
def try_basic_type_conversion(self, param_value: Any, expected_type: Any, param_name: str,bound_args) -> bool: # Try to convert basic types
|
91
|
+
if type(param_value) in [int, str]: # Check if basic type
|
92
|
+
try: # Attempt conversion
|
93
|
+
converted_value = expected_type(param_value) # Convert value
|
94
|
+
bound_args.arguments[param_name] = converted_value # Update bound arguments
|
95
|
+
return True # Return success
|
96
|
+
except Exception: # Handle conversion failure
|
97
|
+
pass # Continue without conversion
|
98
|
+
elif isinstance(param_value, Enum): # Check if value is an Enum
|
99
|
+
try:
|
100
|
+
if issubclass(expected_type, str): # If expecting string type
|
101
|
+
bound_args.arguments[param_name] = param_value.value # Use enum's value
|
102
|
+
return True # Return success
|
103
|
+
except Exception: # Handle conversion failure
|
104
|
+
pass # Continue without conversion
|
105
|
+
return False # Return failure
|
106
|
+
# Return failure
|
100
107
|
|
101
108
|
def validate_direct_type(self, param_name: str, # Validate direct type match
|
102
109
|
param_value: Any, expected_type: Any): # Type parameters
|
osbot_utils/utils/Objects.py
CHANGED
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v1.
|
1
|
+
v1.87.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.87.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
Home-page: https://github.com/owasp-sbot/OSBot-Utils
|
6
6
|
License: MIT
|
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
|
|
23
23
|
|
24
24
|
Powerful Python util methods and classes that simplify common apis and tasks.
|
25
25
|
|
26
|
-

|
27
27
|
[](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
|
28
28
|
|
29
29
|
|
@@ -72,7 +72,7 @@ osbot_utils/helpers/Random_Seed.py,sha256=14btja8LDN9cMGWaz4fCNcMRU_eyx49gas-_PQ
|
|
72
72
|
osbot_utils/helpers/Safe_Id.py,sha256=JbpBWF57Inoq8MgSx1NUy_fjQdpXDjYEp00_MrS5yjs,364
|
73
73
|
osbot_utils/helpers/Timestamp_Now.py,sha256=k3-SUGYx2jLTXvgZYeECqPRJhVxqWPmW7co1l6r12jk,438
|
74
74
|
osbot_utils/helpers/Type_Registry.py,sha256=Ajk3SyMSKDi2g9SJYUtTgg7PZkAgydaHcpbGuEN3S94,311
|
75
|
-
osbot_utils/helpers/Type_Safe_Method.py,sha256=
|
75
|
+
osbot_utils/helpers/Type_Safe_Method.py,sha256=8E88of__An9_ZhJKz6Kp22C1mb9WLED0jWNLOII3fJs,10489
|
76
76
|
osbot_utils/helpers/Zip_Bytes.py,sha256=KB5zWfCf6ET4alNfqNrSp5DxZ3Jp9oDHpc6tK2iO_qg,4320
|
77
77
|
osbot_utils/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
78
78
|
osbot_utils/helpers/ast/Ast.py,sha256=lcPQOSxXI6zgmMnIVF9WM6ISqViWX-sq4d_UC0CDG8s,1155
|
@@ -301,7 +301,7 @@ osbot_utils/utils/Json.py,sha256=0DZGlCU7Nqte5n0r7ctPXFybqA5MRfSrTz5zuK_6UFk,709
|
|
301
301
|
osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
|
302
302
|
osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
|
303
303
|
osbot_utils/utils/Misc.py,sha256=VT-utruCLnZNER5-gYhoGjqe3t-H57SuXcShsJnUSaM,17364
|
304
|
-
osbot_utils/utils/Objects.py,sha256=
|
304
|
+
osbot_utils/utils/Objects.py,sha256=DkE5DLT3SlZBnjr2mTU-S-ZobVRJaUEk0S9SEDxlIPg,19483
|
305
305
|
osbot_utils/utils/Png.py,sha256=V1juGp6wkpPigMJ8HcxrPDIP4bSwu51oNkLI8YqP76Y,1172
|
306
306
|
osbot_utils/utils/Process.py,sha256=lr3CTiEkN3EiBx3ZmzYmTKlQoPdkgZBRjPulMxG-zdo,2357
|
307
307
|
osbot_utils/utils/Python_Logger.py,sha256=tx8N6wRKL3RDHboDRKZn8SirSJdSAE9cACyJkxrThZ8,12792
|
@@ -313,8 +313,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
|
|
313
313
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
314
314
|
osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
|
315
315
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
316
|
-
osbot_utils/version,sha256=
|
317
|
-
osbot_utils-1.
|
318
|
-
osbot_utils-1.
|
319
|
-
osbot_utils-1.
|
320
|
-
osbot_utils-1.
|
316
|
+
osbot_utils/version,sha256=_n4IcOR1rhMha-hwsaQu-wu3MB9FM1Ugs2-IFeeG-iY,8
|
317
|
+
osbot_utils-1.87.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
318
|
+
osbot_utils-1.87.0.dist-info/METADATA,sha256=t5H5yCP99gCrkkKCWMttXIByYWmcddV_LQAdjjFfWCk,1317
|
319
|
+
osbot_utils-1.87.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
320
|
+
osbot_utils-1.87.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|