osbot-utils 2.72.0__py3-none-any.whl → 2.74.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.
Files changed (123) hide show
  1. osbot_utils/helpers/flows/actions/Flow__Data.py +1 -1
  2. osbot_utils/helpers/flows/models/Flow_Run__Event.py +6 -5
  3. osbot_utils/helpers/flows/models/Schema__Flow__Artifact.py +1 -1
  4. osbot_utils/helpers/flows/models/Schema__Flow__Result.py +1 -1
  5. osbot_utils/helpers/flows/schemas/Schema__Flow__Data.py +1 -1
  6. osbot_utils/helpers/flows/schemas/Schema__Flow__Event.py +1 -1
  7. osbot_utils/helpers/flows/schemas/Schema__Flow__Log.py +1 -1
  8. osbot_utils/helpers/flows/schemas/Schema__Flow__Task__Data.py +1 -1
  9. osbot_utils/helpers/generators/Generator_Manager.py +1 -1
  10. osbot_utils/helpers/generators/Model__Generator_Target.py +1 -1
  11. osbot_utils/helpers/html/schemas/Schema__Html_Document.py +1 -1
  12. osbot_utils/helpers/llms/actions/LLM_Request__Execute.py +2 -1
  13. osbot_utils/helpers/llms/actions/Type_Safe__Schema_For__LLMs.py +10 -10
  14. osbot_utils/helpers/llms/builders/LLM_Request__Builder.py +3 -2
  15. osbot_utils/helpers/llms/builders/LLM_Request__Builder__Open_AI.py +2 -1
  16. osbot_utils/helpers/llms/builders/LLM_Request__Factory.py +1 -1
  17. osbot_utils/helpers/llms/cache/LLM_Cache__Path_Generator.py +7 -6
  18. osbot_utils/helpers/llms/cache/LLM_Request__Cache.py +10 -10
  19. osbot_utils/helpers/llms/cache/LLM_Request__Cache__File_System.py +5 -3
  20. osbot_utils/helpers/llms/cache/LLM_Request__Cache__Storage.py +2 -2
  21. osbot_utils/helpers/llms/cache/Virtual_Storage__Local__Folder.py +7 -7
  22. osbot_utils/helpers/llms/cache/Virtual_Storage__Sqlite.py +7 -7
  23. osbot_utils/helpers/llms/schemas/Safe_Str__LLM__Model_Name.py +1 -1
  24. osbot_utils/helpers/llms/schemas/Schema__LLM_Cache__Index.py +6 -5
  25. osbot_utils/helpers/llms/schemas/Schema__LLM_Request__Data.py +2 -1
  26. osbot_utils/helpers/llms/schemas/Schema__LLM_Response.py +1 -1
  27. osbot_utils/helpers/llms/schemas/Schema__LLM_Response__Cache.py +7 -6
  28. osbot_utils/helpers/xml/rss/RSS__Feed__Parser.py +1 -1
  29. osbot_utils/helpers/xml/rss/RSS__Item.py +1 -1
  30. osbot_utils/type_safe/Type_Safe.py +11 -10
  31. osbot_utils/type_safe/Type_Safe__Base.py +3 -3
  32. osbot_utils/{helpers → type_safe/primitives}/safe_float/Safe_Float__Engineering.py +2 -1
  33. osbot_utils/{helpers → type_safe/primitives}/safe_float/Safe_Float__Money.py +1 -2
  34. osbot_utils/{helpers → type_safe/primitives}/safe_float/Safe_Float__Percentage_Exact.py +1 -1
  35. osbot_utils/{helpers → type_safe/primitives}/safe_int/Safe_Int.py +3 -3
  36. osbot_utils/{helpers → type_safe/primitives}/safe_int/__init__.py +1 -1
  37. osbot_utils/{helpers → type_safe/primitives}/safe_str/Safe_Str.py +3 -3
  38. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/cryptography/hashes}/Safe_Str__Hash.py +3 -3
  39. osbot_utils/type_safe/primitives/safe_str/cryptography/hashes/Safe_Str__SHA1.py +26 -0
  40. osbot_utils/type_safe/primitives/safe_str/cryptography/hashes/Safe_Str__SHA1__Short.py +24 -0
  41. osbot_utils/type_safe/primitives/safe_str/cryptography/nacl/Safe_Str__NaCl__Private_Key.py +27 -0
  42. osbot_utils/type_safe/primitives/safe_str/cryptography/nacl/Safe_Str__NaCl__Public_Key.py +28 -0
  43. osbot_utils/type_safe/primitives/safe_str/cryptography/nacl/Schema__NaCl__Keys.py +8 -0
  44. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/filesystem}/Safe_Str__File__Name.py +1 -1
  45. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/filesystem}/Safe_Str__File__Path.py +1 -1
  46. osbot_utils/type_safe/primitives/safe_str/git/Safe_Str__Git__Branch.py +27 -0
  47. osbot_utils/type_safe/primitives/safe_str/git/Safe_Str__Git__Ref.py +63 -0
  48. osbot_utils/type_safe/primitives/safe_str/git/Safe_Str__Git__Ref_Base.py +73 -0
  49. osbot_utils/type_safe/primitives/safe_str/git/Safe_Str__Git__Tag.py +17 -0
  50. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/git}/Safe_Str__Version.py +2 -2
  51. osbot_utils/type_safe/primitives/safe_str/github/Safe_Str__GitHub__Repo.py +46 -0
  52. osbot_utils/type_safe/primitives/safe_str/github/Safe_Str__GitHub__Repo_Name.py +35 -0
  53. osbot_utils/type_safe/primitives/safe_str/github/Safe_Str__GitHub__Repo_Owner.py +39 -0
  54. osbot_utils/type_safe/primitives/safe_str/github/__init__.py +0 -0
  55. osbot_utils/{helpers → type_safe/primitives}/safe_str/http/Safe_Str__Http__Content_Type.py +1 -1
  56. osbot_utils/{helpers → type_safe/primitives}/safe_str/http/Safe_Str__Http__ETag.py +1 -1
  57. osbot_utils/{helpers → type_safe/primitives}/safe_str/http/Safe_Str__Http__Last_Modified.py +1 -1
  58. osbot_utils/{helpers → type_safe/primitives}/safe_str/http/Safe_Str__Http__Text.py +1 -1
  59. osbot_utils/type_safe/primitives/safe_str/http/__init__.py +0 -0
  60. osbot_utils/{helpers → type_safe/primitives/safe_str/identifiers}/Guid.py +3 -2
  61. osbot_utils/type_safe/primitives/safe_str/identifiers/__init__.py +0 -0
  62. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/text}/Safe_Str__Text.py +1 -1
  63. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/text}/Safe_Str__Text__Dangerous.py +1 -1
  64. osbot_utils/type_safe/primitives/safe_str/text/__init__.py +0 -0
  65. osbot_utils/{helpers/safe_str/http → type_safe/primitives/safe_str/web}/Safe_Str__Html.py +1 -1
  66. osbot_utils/{helpers/safe_str → type_safe/primitives/safe_str/web}/Safe_Str__Url.py +1 -1
  67. osbot_utils/type_safe/primitives/safe_str/web/__init__.py +0 -0
  68. osbot_utils/{helpers/safe_int → type_safe/primitives/safe_uint}/Safe_UInt.py +2 -1
  69. osbot_utils/{helpers/safe_int → type_safe/primitives/safe_uint}/Safe_UInt__Byte.py +1 -1
  70. osbot_utils/{helpers/safe_int → type_safe/primitives/safe_uint}/Safe_UInt__FileSize.py +1 -1
  71. osbot_utils/{helpers/safe_int → type_safe/primitives/safe_uint}/Safe_UInt__Percentage.py +1 -1
  72. osbot_utils/{helpers/safe_int → type_safe/primitives/safe_uint}/Safe_UInt__Port.py +1 -1
  73. osbot_utils/type_safe/primitives/safe_uint/__init__.py +0 -0
  74. osbot_utils/type_safe/type_safe_core/__init__.py +0 -0
  75. osbot_utils/type_safe/{Type_Safe__Dict.py → type_safe_core/collections/Type_Safe__Dict.py} +4 -3
  76. osbot_utils/type_safe/type_safe_core/collections/__init__.py +0 -0
  77. osbot_utils/type_safe/type_safe_core/decorators/__init__.py +0 -0
  78. osbot_utils/type_safe/{decorators → type_safe_core/decorators}/type_safe.py +2 -1
  79. osbot_utils/type_safe/{Type_Safe__Method.py → type_safe_core/methods/Type_Safe__Method.py} +4 -5
  80. osbot_utils/type_safe/type_safe_core/methods/__init__.py +0 -0
  81. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Annotations.py +1 -1
  82. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Cache.py +3 -3
  83. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Convert.py +3 -3
  84. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Json_Compressor.py +6 -6
  85. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Raise_Exception.py +1 -1
  86. osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Validation.py +8 -7
  87. osbot_utils/type_safe/type_safe_core/shared/__init__.py +0 -0
  88. osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__Class_Kwargs.py +8 -7
  89. osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__Default_Value.py +6 -6
  90. osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__From_Json.py +16 -17
  91. osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__Init.py +7 -6
  92. osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__Set_Attr.py +7 -7
  93. osbot_utils/type_safe/type_safe_core/steps/__init__.py +0 -0
  94. osbot_utils/utils/Files.py +2 -3
  95. osbot_utils/version +1 -1
  96. osbot_utils-2.74.0.dist-info/METADATA +212 -0
  97. {osbot_utils-2.72.0.dist-info → osbot_utils-2.74.0.dist-info}/RECORD +122 -98
  98. osbot_utils-2.72.0.dist-info/METADATA +0 -44
  99. /osbot_utils/{helpers/safe_float → type_safe/primitives}/__init__.py +0 -0
  100. /osbot_utils/{helpers → type_safe/primitives}/safe_float/Safe_Float.py +0 -0
  101. /osbot_utils/{helpers/safe_str → type_safe/primitives/safe_float}/__init__.py +0 -0
  102. /osbot_utils/{helpers → type_safe/primitives/safe_int}/Timestamp_Now.py +0 -0
  103. /osbot_utils/{helpers/safe_str/schemas → type_safe/primitives/safe_str}/Enum__Safe_Str__Regex_Mode.py +0 -0
  104. /osbot_utils/{helpers/safe_str/http → type_safe/primitives/safe_str}/__init__.py +0 -0
  105. /osbot_utils/{helpers/safe_str/schemas → type_safe/primitives/safe_str/cryptography}/__init__.py +0 -0
  106. /osbot_utils/type_safe/{decorators → primitives/safe_str/cryptography/hashes}/__init__.py +0 -0
  107. /osbot_utils/type_safe/{methods → primitives/safe_str/cryptography/nacl}/__init__.py +0 -0
  108. /osbot_utils/type_safe/{shared → primitives/safe_str/filesystem}/__init__.py +0 -0
  109. /osbot_utils/type_safe/{steps → primitives/safe_str/git}/__init__.py +0 -0
  110. /osbot_utils/{helpers → type_safe/primitives/safe_str/identifiers}/Random_Guid.py +0 -0
  111. /osbot_utils/{helpers → type_safe/primitives/safe_str/identifiers}/Random_Guid_Short.py +0 -0
  112. /osbot_utils/{helpers → type_safe/primitives/safe_str/identifiers}/Safe_Id.py +0 -0
  113. /osbot_utils/{helpers/safe_str/http → type_safe/primitives/safe_str/web}/Safe_Str__IP_Address.py +0 -0
  114. /osbot_utils/type_safe/{Type_Safe__List.py → type_safe_core/collections/Type_Safe__List.py} +0 -0
  115. /osbot_utils/type_safe/{Type_Safe__Set.py → type_safe_core/collections/Type_Safe__Set.py} +0 -0
  116. /osbot_utils/type_safe/{Type_Safe__Tuple.py → type_safe_core/collections/Type_Safe__Tuple.py} +0 -0
  117. /osbot_utils/type_safe/{methods → type_safe_core/methods}/type_safe_property.py +0 -0
  118. /osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Json_Compressor__Type_Registry.py +0 -0
  119. /osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Not_Cached.py +0 -0
  120. /osbot_utils/type_safe/{shared → type_safe_core/shared}/Type_Safe__Shared__Variables.py +0 -0
  121. /osbot_utils/type_safe/{steps → type_safe_core/steps}/Type_Safe__Step__Default_Kwargs.py +0 -0
  122. {osbot_utils-2.72.0.dist-info → osbot_utils-2.74.0.dist-info}/LICENSE +0 -0
  123. {osbot_utils-2.72.0.dist-info → osbot_utils-2.74.0.dist-info}/WHEEL +0 -0
@@ -1,10 +1,11 @@
1
- from typing import Dict, Any, Type
2
- from osbot_utils.helpers.Obj_Id import Obj_Id
3
- from osbot_utils.helpers.Random_Guid import Random_Guid
4
- from osbot_utils.type_safe.shared.Type_Safe__Cache import Type_Safe__Cache, type_safe_cache
5
- from osbot_utils.type_safe.shared.Type_Safe__Shared__Variables import IMMUTABLE_TYPES
6
- from osbot_utils.type_safe.shared.Type_Safe__Validation import type_safe_validation
7
- from osbot_utils.type_safe.steps.Type_Safe__Step__Default_Value import type_safe_step_default_value
1
+ from typing import Dict, Any, Type
2
+ from osbot_utils.helpers.Obj_Id import Obj_Id
3
+ from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid import Random_Guid
4
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache import type_safe_cache, Type_Safe__Cache
5
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Shared__Variables import IMMUTABLE_TYPES
6
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Validation import type_safe_validation
7
+ from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Default_Value import type_safe_step_default_value
8
+
8
9
 
9
10
  class Type_Safe__Step__Class_Kwargs: # Handles class-level keyword arguments processing
10
11
 
@@ -1,12 +1,12 @@
1
1
  import sys
2
2
  import inspect
3
3
  import typing
4
- from osbot_utils.type_safe.Type_Safe__Set import Type_Safe__Set
5
- from osbot_utils.type_safe.Type_Safe__Tuple import Type_Safe__Tuple
6
- from osbot_utils.type_safe.shared.Type_Safe__Cache import type_safe_cache
7
- from osbot_utils.utils.Objects import default_value
8
- from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
9
- from osbot_utils.type_safe.Type_Safe__Dict import Type_Safe__Dict
4
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Dict import Type_Safe__Dict
5
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
6
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Set import Type_Safe__Set
7
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Tuple import Type_Safe__Tuple
8
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache import type_safe_cache
9
+ from osbot_utils.utils.Objects import default_value
10
10
 
11
11
 
12
12
  # Backport implementations of get_args for Python 3.7 # todo: refactor into separate class (focused on past python version compatibility)
@@ -1,20 +1,21 @@
1
1
  import sys
2
2
  import types
3
- from decimal import Decimal
4
- from enum import EnumMeta
5
- from osbot_utils.helpers.Obj_Id import Obj_Id
6
- from osbot_utils.helpers.safe_str.Safe_Str__Hash import Safe_Str__Hash
7
- from osbot_utils.type_safe.Type_Safe import Type_Safe
8
- from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
9
- from osbot_utils.helpers.Random_Guid import Random_Guid
10
- from osbot_utils.helpers.Random_Guid_Short import Random_Guid_Short
11
- from osbot_utils.type_safe.Type_Safe__Set import Type_Safe__Set
12
- from osbot_utils.type_safe.shared.Type_Safe__Annotations import type_safe_annotations
13
- from osbot_utils.type_safe.shared.Type_Safe__Cache import type_safe_cache
14
- from osbot_utils.type_safe.shared.Type_Safe__Convert import type_safe_convert
15
- from osbot_utils.utils.Objects import enum_from_value
16
- from osbot_utils.helpers.Safe_Id import Safe_Id
17
- from osbot_utils.helpers.Timestamp_Now import Timestamp_Now
3
+ from decimal import Decimal
4
+ from enum import EnumMeta
5
+ from osbot_utils.helpers.Obj_Id import Obj_Id
6
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
7
+ from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid import Random_Guid
8
+ from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid_Short import Random_Guid_Short
9
+ from osbot_utils.type_safe.primitives.safe_str.cryptography.hashes.Safe_Str__Hash import Safe_Str__Hash
10
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Dict import Type_Safe__Dict
11
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
12
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Set import Type_Safe__Set
13
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Annotations import type_safe_annotations
14
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache import type_safe_cache
15
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Convert import type_safe_convert
16
+ from osbot_utils.utils.Objects import enum_from_value
17
+ from osbot_utils.type_safe.primitives.safe_str.identifiers.Safe_Id import Safe_Id
18
+ from osbot_utils.type_safe.primitives.safe_int.Timestamp_Now import Timestamp_Now
18
19
 
19
20
  # todo; refactor all this python compatibility into the python_3_8 class
20
21
  if sys.version_info < (3, 8): # pragma: no cover
@@ -148,8 +149,6 @@ class Type_Safe__Step__From_Json:
148
149
  return value
149
150
 
150
151
  def deserialize_dict__using_key_value_annotations(self, _self, key, value):
151
- from osbot_utils.type_safe.Type_Safe__Dict import Type_Safe__Dict
152
-
153
152
  annotations = type_safe_cache.get_obj_annotations(_self)
154
153
  dict_annotations_tuple = get_args(annotations.get(key))
155
154
  if not dict_annotations_tuple: # happens when the value is a dict/Dict with no annotations
@@ -1,7 +1,12 @@
1
1
  from enum import EnumMeta
2
2
  from typing import ForwardRef
3
- from osbot_utils.type_safe.shared.Type_Safe__Annotations import type_safe_annotations
4
- from osbot_utils.type_safe.steps.Type_Safe__Step__Default_Value import type_safe_step_default_value, get_args
3
+
4
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Dict import Type_Safe__Dict
5
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
6
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Set import Type_Safe__Set
7
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Tuple import Type_Safe__Tuple
8
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Annotations import type_safe_annotations
9
+ from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Default_Value import type_safe_step_default_value, get_args
5
10
 
6
11
 
7
12
  class Type_Safe__Step__Init:
@@ -46,7 +51,6 @@ class Type_Safe__Step__Init:
46
51
  value = type_safe_step_default_value.default_value(__self.__class__, annotation) # Use default_value to create the proper type-safe container
47
52
  # Handle non-empty list
48
53
  elif origin is list and isinstance(value, list):
49
- from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
50
54
  item_type = get_args(annotation)[0]
51
55
  if isinstance(item_type, ForwardRef):
52
56
  forward_name = item_type.__forward_arg__
@@ -59,7 +63,6 @@ class Type_Safe__Step__Init:
59
63
 
60
64
  # Handle non-empty set
61
65
  elif origin is set and isinstance(value, set):
62
- from osbot_utils.type_safe.Type_Safe__Set import Type_Safe__Set
63
66
  item_type = get_args(annotation)[0]
64
67
  type_safe_set = Type_Safe__Set(expected_type=item_type)
65
68
  for item in value:
@@ -68,13 +71,11 @@ class Type_Safe__Step__Init:
68
71
 
69
72
  # Handle non-empty tuple
70
73
  elif origin is tuple and isinstance(value, tuple):
71
- from osbot_utils.type_safe.Type_Safe__Tuple import Type_Safe__Tuple
72
74
  item_types = get_args(annotation)
73
75
  return Type_Safe__Tuple(expected_types=item_types, items=value)
74
76
 
75
77
  # Handle non-empty dict
76
78
  elif origin is dict and isinstance(value, dict):
77
- from osbot_utils.type_safe.Type_Safe__Dict import Type_Safe__Dict
78
79
  key_type, value_type = get_args(annotation)
79
80
  type_safe_dict = Type_Safe__Dict(expected_key_type=key_type, expected_value_type=value_type)
80
81
  for k, v in value.items():
@@ -1,9 +1,9 @@
1
1
  from typing import get_origin, Annotated, get_args
2
- from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
3
2
  from osbot_utils.type_safe.Type_Safe__Primitive import Type_Safe__Primitive
4
- from osbot_utils.type_safe.shared.Type_Safe__Cache import type_safe_cache
5
- from osbot_utils.type_safe.shared.Type_Safe__Convert import type_safe_convert
6
- from osbot_utils.type_safe.shared.Type_Safe__Validation import type_safe_validation
3
+ from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
4
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache import type_safe_cache
5
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Convert import type_safe_convert
6
+ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Validation import type_safe_validation
7
7
  from osbot_utils.type_safe.validators.Type_Safe__Validator import Type_Safe__Validator
8
8
 
9
9
  class Type_Safe__Step__Set_Attr:
@@ -67,9 +67,9 @@ class Type_Safe__Step__Set_Attr:
67
67
  attribute.validate(value=value, field_name=name, target_type=target_type)
68
68
 
69
69
  def handle_get_class__dict(self, _self, name, value):
70
- if value: # todo: see side effects of doing this here (since going into deserialize_dict__using_key_value_annotations has performance hit)
71
- from osbot_utils.type_safe.steps.Type_Safe__Step__From_Json import Type_Safe__Step__From_Json # here because of circular dependencies
72
- value = Type_Safe__Step__From_Json().deserialize_dict__using_key_value_annotations(_self, name, value) # todo: refactor how this actually works since it is not good to having to use the deserialize_dict__using_key_value_annotations from here
70
+ if value: # todo: see side effects of doing this here (since going into deserialize_dict__using_key_value_annotations has performance hit)
71
+ from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__From_Json import Type_Safe__Step__From_Json # here because of circular dependencies
72
+ value = Type_Safe__Step__From_Json().deserialize_dict__using_key_value_annotations(_self, name, value) # todo: refactor how this actually works since it is not good to having to use the deserialize_dict__using_key_value_annotations from here
73
73
  return value
74
74
 
75
75
  def handle_get_class(self, _self, annotations, name, value):
File without changes
@@ -1,7 +1,6 @@
1
1
  import os
2
- from typing import Union, List
3
-
4
- from osbot_utils.helpers.safe_str.Safe_Str__File__Path import Safe_Str__File__Path
2
+ from typing import Union, List
3
+ from osbot_utils.type_safe.primitives.safe_str.filesystem.Safe_Str__File__Path import Safe_Str__File__Path
5
4
 
6
5
 
7
6
  class Files:
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.72.0
1
+ v2.74.0
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.3
2
+ Name: osbot_utils
3
+ Version: 2.74.0
4
+ Summary: OWASP Security Bot - Utils
5
+ License: MIT
6
+ Author: Dinis Cruz
7
+ Author-email: dinis.cruz@owasp.org
8
+ Requires-Python: >=3.7,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Project-URL: Homepage, https://github.com/owasp-sbot/OSBot-Utils
19
+ Project-URL: Repository, https://github.com/owasp-sbot/OSBot-Utils
20
+ Description-Content-Type: text/markdown
21
+
22
+ # OSBot-Utils
23
+
24
+ ![Current Release](https://img.shields.io/badge/release-v2.74.0-blue)
25
+ ![Python](https://img.shields.io/badge/python-3.8+-green)
26
+ ![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)
27
+ ![Caching](https://img.shields.io/badge/Caching-Built--In-orange)
28
+ [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
29
+
30
+ A comprehensive Python utility toolkit providing **Type-Safe primitives**, decorators, caching layers, HTML/AST helpers, SQLite tooling, SSH execution, LLM request pipelines, tracing, and more — all designed to accelerate building robust, maintainable automation and integration code.
31
+
32
+ ---
33
+
34
+ ## ✨ Key Features
35
+
36
+ * **🛡️ Type-Safe First**: Strongly typed primitives (`Safe_Str`, `Safe_Int`, `Safe_Float`, etc.) with validation and sanitization
37
+ * **⚡ Multi-layer Caching**: In-memory, per-instance, pickle-on-disk, temp-file, and request/response caches
38
+ * **🗂️ Rich Utilities**: Helpers for HTML parsing/rendering, AST inspection, SSH/SCP execution, SQLite schema management, and more
39
+ * **🧠 LLM Support**: Structured request builders, OpenAI API integration, schema enforcement, and persistent cache
40
+ * **🔍 Tracing & Debugging**: Full function call tracing with configurable depth, locals capture, and pretty output
41
+ * **🧪 Testing Utilities**: Temp SQLite DBs, mockable caches, and easy test helpers
42
+
43
+ ---
44
+
45
+ ## 📦 Installation
46
+
47
+ ```bash
48
+ pip install osbot-utils
49
+ ```
50
+
51
+ From source:
52
+
53
+ ```bash
54
+ pip install git+https://github.com/owasp-sbot/OSBot-Utils.git@dev
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🚀 Quick Start
60
+
61
+ ### Using Type-Safe Primitives
62
+
63
+ ```python
64
+ from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
65
+
66
+ class Username(Safe_Str):
67
+ max_length = 20
68
+
69
+ print(Username("alice")) # 'alice'
70
+ print(Username("invalid username!")) # 'invalid_username_'
71
+ ```
72
+
73
+ ---
74
+
75
+ ### Simple In-Memory Caching
76
+
77
+ ```python
78
+ from osbot_utils.decorators.methods.cache_on_self import cache_on_self
79
+
80
+ class DataFetcher:
81
+ @cache_on_self
82
+ def fetch(self, x):
83
+ print("Fetching…")
84
+ return x * 2
85
+
86
+ fetcher = DataFetcher()
87
+ fetcher.fetch(10) # Calls method
88
+ fetcher.fetch(10) # Returns cached result
89
+ ```
90
+
91
+ ---
92
+
93
+ ### HTML Parsing
94
+
95
+ ```python
96
+ from osbot_utils.helpers.html.Html__To__Html_Dict import html_to_dict
97
+
98
+ html_code = "<html><body><h1>Hello</h1></body></html>"
99
+ print(html_to_dict(html_code))
100
+ ```
101
+
102
+ ---
103
+
104
+ ### SQLite Dynamic Table
105
+
106
+ ```python
107
+ from osbot_utils.helpers.sqlite.Temp_Sqlite__Table import Temp_Sqlite__Table
108
+
109
+ with Temp_Sqlite__Table() as table:
110
+ table.row_schema = type("Row", (), {"name": str, "age": int})
111
+ table.create()
112
+ table.add_row_and_commit(name="Alice", age=30)
113
+ print(table.rows())
114
+ ```
115
+
116
+ ---
117
+
118
+ ### LLM Request Execution
119
+
120
+ ```python
121
+ from osbot_utils.helpers.llms.builders.LLM_Request__Builder__Open_AI import LLM_Request__Builder__Open_AI
122
+ from osbot_utils.helpers.llms.actions.LLM_Request__Execute import LLM_Request__Execute
123
+
124
+ builder = LLM_Request__Builder__Open_AI()
125
+ builder.set__model__gpt_4o().add_message__user("Say hi in JSON")
126
+
127
+ executor = LLM_Request__Execute(request_builder=builder)
128
+ response = executor.execute(builder.llm_request())
129
+ print(response.response_data)
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 🏗️ Architecture
135
+
136
+ OSBot-Utils is organized into core **Type-Safe foundations** with layered utilities for different domains:
137
+
138
+ ```
139
+ ┌──────────────────────────────────────────────┐
140
+ │ Your Code │
141
+ │ ┌───────────┐ ┌─────────────┐ ┌──────────┐ │
142
+ │ │ Type-Safe │ │ Decorators │ │ Helpers │ │
143
+ │ │ Primitives│ │ & Caching │ │ (HTML, │ │
144
+ │ │ │ │ │ │ AST, │ │
145
+ │ │ │ │ │ │ SQLite)│ │
146
+ │ └───────────┘ └─────────────┘ └──────────┘ │
147
+ └──────────────────────────┬───────────────────┘
148
+
149
+ ┌──────────────────────────▼───────────────────┐
150
+ │ OSBot-Utils │
151
+ │ ┌────────────────────────────────────────┐ │
152
+ │ │ Type-Safe Core Classes │ │
153
+ │ │ Validation / Sanitization / Defaults │ │
154
+ │ └────────────────────────────────────────┘ │
155
+ │ ┌────────────────────────────────────────┐ │
156
+ │ │ Caching Layers & Decorators │ │
157
+ │ │ @cache, @cache_on_self, pickle, tmp │ │
158
+ │ └────────────────────────────────────────┘ │
159
+ │ ┌────────────────────────────────────────┐ │
160
+ │ │ Domain Helpers │ │
161
+ │ │ HTML, AST, SSH, LLMs, SQLite, Tracing │ │
162
+ │ └────────────────────────────────────────┘ │
163
+ └──────────────────────────────────────────────┘
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 📚 Key Modules
169
+
170
+ * **`helpers/safe_*`** — Type-Safe primitives for validated strings, ints, floats
171
+ * **`decorators/methods`** — Caching, exception capture, timing, validation
172
+ * **`helpers/html`** — HTML ↔ dict ↔ tag classes
173
+ * **`helpers/ast`** — Python AST parsing, visiting, merging
174
+ * **`helpers/sqlite`** — High-level SQLite APIs, schema generation, temp DBs
175
+ * **`helpers/ssh`** — SSH/SCP execution with caching
176
+ * **`helpers/llms`** — LLM request/response handling with caching
177
+ * **`helpers/trace`** — Function call tracing with configurable output
178
+
179
+ ---
180
+
181
+ ## 🎯 Benefits
182
+
183
+ ### For Developers
184
+
185
+ * Strong runtime type validation with Type-Safe classes
186
+ * Consistent patterns for caching and decorators
187
+ * Rich helper library to avoid reinventing the wheel
188
+
189
+ ### For Production
190
+
191
+ * Deterministic caching with persistence options
192
+ * Safe, validated data structures at integration boundaries
193
+ * Lightweight, dependency-minimal utilities
194
+
195
+ ### For Teams
196
+
197
+ * Standardized approach to cross-cutting concerns (logging, tracing, caching)
198
+ * Modular helpers to fit many contexts (CLI, web apps, serverless)
199
+
200
+ ---
201
+
202
+ ## 🤝 Contributing
203
+
204
+ Pull requests are welcome!
205
+ Check existing patterns in `/helpers` and `/decorators` for style guidance.
206
+
207
+ ---
208
+
209
+ ## 📄 License
210
+
211
+ Licensed under the Apache 2.0 License.
212
+