Skip to content

Commit

Permalink
Merge dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Jan 24, 2025
2 parents e94670a + a694ef6 commit c45beb9
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 1,237 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Powerful Python util methods and classes that simplify common apis and tasks.

![Current Release](https://img.shields.io/badge/release-v2.16.0-blue)
![Current Release](https://img.shields.io/badge/release-v2.16.5-blue)
[![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)


Expand Down
922 changes: 116 additions & 806 deletions docs/code/osbot_utils/type_safe/Type_Safe.py.md

Large diffs are not rendered by default.

647 changes: 222 additions & 425 deletions docs/code/osbot_utils/type_safe/Type_Safe.py.review.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions osbot_utils/type_safe/Type_Safe__Base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import get_args, Union, Optional, Any, ForwardRef
from osbot_utils.helpers.Obj_Id import Obj_Id
from osbot_utils.type_safe.shared.Type_Safe__Cache import type_safe_cache

EXACT_TYPE_MATCH = (int, float, str, bytes, bool, complex)
Expand Down Expand Up @@ -63,6 +64,8 @@ def is_instance_of_type(self, item, expected_type):
if len(args) != len(item):
raise TypeError(f"Expected tuple of length {len(args)}, but got {len(item)}")
for idx, (elem, elem_type) in enumerate(zip(item, args)):
if elem_type is Obj_Id: # todo: refactor this out, and figure out better way to handle this kind of de-serialisation
elem = elem_type(elem)
try:
self.is_instance_of_type(elem, elem_type)
except TypeError as e:
Expand Down
2 changes: 1 addition & 1 deletion osbot_utils/type_safe/shared/Type_Safe__Validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def validate_type_immutability(self, var_name: str, var_type: Any) -> None:
type_safe_raise_exception.immutable_type_error(var_name, var_type)

def validate_variable_type(self, var_name, var_type, var_value): # Validate type compatibility
if var_type and not isinstance(var_value, var_type):
if type(var_type) is type and not isinstance(var_value, var_type):
type_safe_raise_exception.type_mismatch_error(var_name, var_type, type(var_value))

type_safe_validation = Type_Safe__Validation()
3 changes: 2 additions & 1 deletion osbot_utils/utils/Json.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def json_save_tmp_file(python_object, pretty=True):
json_file_contents = Json.load_file
json_file_contents_gz = Json.load_file_gz
json_file_load = Json.load_file
json_file_safe = Json.save_file
json_file_save = Json.save_file
json_from_file = Json.load_file
json_load_file = Json.load_file
json_load_file_and_delete = Json.load_file_and_delete
Expand All @@ -184,6 +184,7 @@ def json_save_tmp_file(python_object, pretty=True):
json_parse = Json.loads
json_lines_parse = Json.loads_json_lines
json_to_bytes = json_dumps_to_bytes
json_to_file = json_file_save
json_to_str = json_dumps
json_round_trip = Json.round_trip
json_save = Json.save_file
Expand Down
2 changes: 1 addition & 1 deletion osbot_utils/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.16.0
v2.16.5
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "osbot_utils"
version = "v2.16.0"
version = "v2.16.5"
description = "OWASP Security Bot - Utils"
authors = ["Dinis Cruz <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/helpers/test_Obj_Id.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_new_obj_id(self):

def test__perf__new__(self):
with Performance_Measure__Session() as _:
_.measure(lambda: Obj_Id() ).assert_time__less_than(600)
_.measure(lambda: Obj_Id() ).assert_time__less_than(700)

def test__perf__new_obj_id(self):
with Performance_Measure__Session() as _:
Expand Down

0 comments on commit c45beb9

Please sign in to comment.