Skip to content

Commit acdc298

Browse files
committed
Merge dev into main
2 parents 55e3355 + 23c177d commit acdc298

File tree

7 files changed

+436
-8
lines changed

7 files changed

+436
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OSBot-Utils
22

3-
![Current Release](https://img.shields.io/badge/release-v3.54.0-blue)
3+
![Current Release](https://img.shields.io/badge/release-v3.54.1-blue)
44
![Python](https://img.shields.io/badge/python-3.8+-green)
55
![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)
66
![Caching](https://img.shields.io/badge/Caching-Built--In-orange)

osbot_utils/type_safe/type_safe_core/shared/Type_Safe__Validation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def are_types_compatible_for_assigment(self, source_type, target_type):
2222
import types
2323
import typing
2424

25+
if source_type is None:
26+
return target_type is type(None) or target_type is None or target_type is typing.Any
27+
28+
2529
if isinstance(target_type, str): # If the "target_type" is a forward reference (string), handle it here.
2630
if target_type == source_type.__name__: # Simple check: does the string match the actual class name
2731
return True
@@ -119,6 +123,13 @@ def check_if__type_matches__union_type(self, annotation : Any,
119123
if value_type in args: # Direct match
120124
return True
121125

126+
if value_type is types.FunctionType: # Handle Callable types within Union (e.g., Optional[Callable[[str], None]]), hen value_type is a function, check if any union arg is a compatible Callable
127+
for arg in args:
128+
arg_origin = type_safe_cache.get_origin(arg)
129+
if arg_origin is collections.abc.Callable:
130+
return True # Accept functions for Callable annotations in unions , Full signature validation happens elsewhere
131+
132+
122133
if value_type in TYPE_MAPPINGS: # Check for typing generics equivalence
123134
if TYPE_MAPPINGS[value_type] in args: # If value_type is a built-in, check if its typing equivalent is in args
124135
return True

osbot_utils/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.54.0
1+
v3.54.1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "osbot_utils"
3-
version = "v3.54.0"
3+
version = "v3.54.1"
44
description = "OWASP Security Bot - Utils"
55
authors = ["Dinis Cruz <[email protected]>"]
66
license = "MIT"

tests/unit/helpers/html/transformers/test_Html__To__Html_Dict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from unittest import TestCase
1+
from unittest import TestCase
22
from osbot_utils.helpers.html.transformers.Html_Dict__To__Html import Html_Dict__To__Html
33
from osbot_utils.helpers.html.transformers.Html__To__Html_Dict import Html__To__Html_Dict, STRING__SCHEMA_TEXT
4-
from tests._test_data.Sample_Test_Files import Sample_Test_Files
4+
from tests._test_data.Sample_Test_Files import Sample_Test_Files
55

66

77
class test_Html__To__Html_Dict(TestCase):

tests/unit/type_safe/type_safe_core/_bugs/test_Type_Safe__bugs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,4 @@ class Extended_Config(Base_Config):
9797
# because Base_Handler is not a subclass of Extended_Handler
9898
error_message = "On Extended_Config, invalid type for attribute 'handler_type'. Expected 'typing.Type["
9999
with pytest.raises(ValueError, match=re.escape(error_message)):
100-
Extended_Config() # BUG: should auto-assign Extended_Handler
101-
102-
100+
Extended_Config() # BUG: should auto-assign Extended_Handler

0 commit comments

Comments
 (0)