osbot-utils 1.65.0__py3-none-any.whl → 1.66.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.
@@ -19,7 +19,7 @@ from osbot_utils.utils.Misc import list_set
19
19
  from osbot_utils.utils.Objects import default_value, value_type_matches_obj_annotation_for_attr, \
20
20
  raise_exception_on_obj_type_annotation_mismatch, obj_is_attribute_annotation_of_type, enum_from_value, \
21
21
  obj_is_type_union_compatible, value_type_matches_obj_annotation_for_union_attr, \
22
- convert_dict_to_value_from_obj_annotation, dict_to_obj, convert_str_to_value_from_obj_annotation
22
+ convert_dict_to_value_from_obj_annotation, dict_to_obj, convert_to_value_from_obj_annotation
23
23
 
24
24
  # Backport implementations of get_origin and get_args for Python 3.7
25
25
  if sys.version_info < (3, 8): # pragma: no cover
@@ -99,8 +99,8 @@ class Type_Safe:
99
99
  if value is not None:
100
100
  if type(value) is dict:
101
101
  value = convert_dict_to_value_from_obj_annotation(self, name, value)
102
- if type(value) is str:
103
- value = convert_str_to_value_from_obj_annotation (self, name, value)
102
+ if type(value) in [int, str]: # for now only a small number of str and int classes are supported (until we understand the full implications of this)
103
+ value = convert_to_value_from_obj_annotation (self, name, value)
104
104
  check_1 = value_type_matches_obj_annotation_for_attr (self, name, value)
105
105
  check_2 = value_type_matches_obj_annotation_for_union_attr(self, name, value)
106
106
  if (check_1 is False and check_2 is None or
@@ -8,10 +8,13 @@ import typing
8
8
  from collections.abc import Mapping
9
9
  from typing import Union
10
10
  from types import SimpleNamespace
11
+ from osbot_utils.helpers.Timestamp_Now import Timestamp_Now
11
12
  from osbot_utils.helpers.Random_Guid import Random_Guid
12
13
  from osbot_utils.utils.Misc import list_set
13
14
  from osbot_utils.utils.Str import str_unicode_escape, str_max_width
14
15
 
16
+ TYPE_SAFE__CONVERT_VALUE__SUPPORTED_TYPES = [Random_Guid, Timestamp_Now]
17
+
15
18
  # Backport implementations of get_origin and get_args for Python 3.7
16
19
  if sys.version_info < (3, 8):
17
20
  def get_origin(tp):
@@ -105,14 +108,14 @@ def convert_dict_to_value_from_obj_annotation(target, attr_name, value):
105
108
  return attribute_annotation(**value)
106
109
  return value
107
110
 
108
- def convert_str_to_value_from_obj_annotation(target, attr_name, value): # todo: see the side effects of doing this for all strings
111
+ def convert_to_value_from_obj_annotation(target, attr_name, value): # todo: see the side effects of doing this for all ints and floats
109
112
  if target is not None and attr_name is not None:
110
113
  if hasattr(target, '__annotations__'):
111
114
  obj_annotations = target.__annotations__
112
115
  if hasattr(obj_annotations,'get'):
113
116
  attribute_annotation = obj_annotations.get(attr_name)
114
- if 'str' in base_classes_names(attribute_annotation): # todo: figure out a better way to handle these special type casting (used for example by Random_Guid)
115
- if attribute_annotation == Random_Guid: # and add support for other types like int (which is used my Timestamp_Now)
117
+ if attribute_annotation:
118
+ if attribute_annotation in TYPE_SAFE__CONVERT_VALUE__SUPPORTED_TYPES: # for now hard-coding this to just these types until we understand the side effects
116
119
  return attribute_annotation(value)
117
120
  return value
118
121
 
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v1.65.0
1
+ v1.66.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osbot_utils
3
- Version: 1.65.0
3
+ Version: 1.66.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
- ![Current Release](https://img.shields.io/badge/release-v1.65.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v1.66.0-blue)
27
27
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
28
28
 
29
29
 
@@ -2,7 +2,7 @@ osbot_utils/__init__.py,sha256=DdJDmQc9zbQUlPVyTJOww6Ixrn9n4bD3ami5ItQfzJI,16
2
2
  osbot_utils/base_classes/Cache_Pickle.py,sha256=kPCwrgUbf_dEdxUz7vW1GuvIPwlNXxuRhb-H3AbSpII,5884
3
3
  osbot_utils/base_classes/Kwargs_To_Disk.py,sha256=HHoy05NC_w35WcT-OnSKoSIV_cLqaU9rdjH0_KNTM0E,1096
4
4
  osbot_utils/base_classes/Kwargs_To_Self.py,sha256=weFNsBfBNV9W_qBkN-IdBD4yYcJV_zgTxBRO-ZlcPS4,141
5
- osbot_utils/base_classes/Type_Safe.py,sha256=FH_q3PJb_Fa4FAjG1fzuaEAt-lv7Ila-2ZNPd_Ohors,18621
5
+ osbot_utils/base_classes/Type_Safe.py,sha256=N1RMyDEA9YFI5MciixobxM0ZjbEQpPtj8XzmzTrPTls,18789
6
6
  osbot_utils/base_classes/Type_Safe__List.py,sha256=-80C9OhsK6iDR2dAG8yNLAZV0qg5x3faqvSUigFCMJw,517
7
7
  osbot_utils/base_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  osbot_utils/context_managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -293,7 +293,7 @@ osbot_utils/utils/Json.py,sha256=yIT2hUI23gYd24Uf3LCjqPNV67zS46rYZftcCM3jw-Q,649
293
293
  osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
294
294
  osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
295
295
  osbot_utils/utils/Misc.py,sha256=4MkG2BE1VzZfV4KPzYZ4jVAoUwoA3pTTVPi609ldLGA,16961
296
- osbot_utils/utils/Objects.py,sha256=vPJdfpzwSRykcVkVT-ztaCC_52AWPVey9uWrJ9rAvZ8,18722
296
+ osbot_utils/utils/Objects.py,sha256=sYBpcKfvG3QRE5NSet_9e9MqOhRvKGowuWkGDtijY1g,18724
297
297
  osbot_utils/utils/Png.py,sha256=V1juGp6wkpPigMJ8HcxrPDIP4bSwu51oNkLI8YqP76Y,1172
298
298
  osbot_utils/utils/Process.py,sha256=lr3CTiEkN3EiBx3ZmzYmTKlQoPdkgZBRjPulMxG-zdo,2357
299
299
  osbot_utils/utils/Python_Logger.py,sha256=tx8N6wRKL3RDHboDRKZn8SirSJdSAE9cACyJkxrThZ8,12792
@@ -305,8 +305,8 @@ osbot_utils/utils/Toml.py,sha256=SD6IA4-mrtoBXcI0dIGKV9POMQNd6WYKvmDQq7GQ6ZQ,143
305
305
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
306
306
  osbot_utils/utils/Zip.py,sha256=G6Hk_hDcm9yvWzhTKzhT0R_6f0NBIAchHqMxGb3kfh4,14037
307
307
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
308
- osbot_utils/version,sha256=6rsAH6KPsBZcwclONfSWT6iY8kMQH684ZSqdZ73t7m0,8
309
- osbot_utils-1.65.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
310
- osbot_utils-1.65.0.dist-info/METADATA,sha256=DdYjLZWifnhmxlOX4Bl9jcJqZg4qY82E-7km6kF279g,1317
311
- osbot_utils-1.65.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
312
- osbot_utils-1.65.0.dist-info/RECORD,,
308
+ osbot_utils/version,sha256=1QcmI8mVRJJdlWulkPzEykBmlNbrD6QZ-4jQHNIZtDc,8
309
+ osbot_utils-1.66.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
310
+ osbot_utils-1.66.0.dist-info/METADATA,sha256=IlgcQwbhyJQ9y7RWr1xQVk93pvICSope8bUxaWV2bdM,1317
311
+ osbot_utils-1.66.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
312
+ osbot_utils-1.66.0.dist-info/RECORD,,