Skip to content

Commit

Permalink
Itervalidator (#59)
Browse files Browse the repository at this point in the history
* [DRAFT] maybe some future implementations

* [FEAT] ValidationType to add validation functions to type annotation

* [FEAT] docstring from type annotations

* [FEAT] docstring from type annotations

* [UPD] add testing

* [FIX] issue when extension module is installed

* [UPD] separate test with py3.9 only syntax

* [UPD] skip specific test when running with installed module

* fixup!

* [UPD] better info for typing.Literal

* fixup!

* [UPD] include new feature information

* [UPD] beta version

* [UPD] mkdocs for readthedocs

* [UPD] include readthedocs conf

* Update .readthedocs.yaml

* Update .readthedocs.yaml

* .

* .

* fixup!

* fixup!fixup!

* fixup!fixup!fixup!

* fixup!fixup!fixup!fixup!

* fixup!

* [UPD] docs

* fixup!

* [FIX] missing iterable check

* [FIX] include missing type check for Iterable

* isort: .

* isort: .

* black: .

* [FIX] better info when Validator is wrong used

* [FEAT] IterValidator which calls the function on each element like map
[FIX] several fixes

* [FIX] cover failing test in pytest.raises

* linting

* [UPD] version

* [UPD] docs

* [FIX] merge conflict

* [FIX] typing.Any and IterValidator

* [FIX] typing.Any and IterValidator

Co-authored-by: eisenmenger <[email protected]>
  • Loading branch information
FelixTheC and eisenmenger authored May 30, 2021
1 parent 502b355 commit 4e37663
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release Notes


## v2.1.4
- fix `IterValidator` with typing.Any

## v2.1.3
- moving `Validator` to `strongtyping.types`
- fixing some bugs
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="strongtyping",
version="2.1.3",
version="2.1.4",
description="Decorator which checks whether the function is called with the correct type of parameters",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
7 changes: 5 additions & 2 deletions strongtyping/strong_typing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ def validate_object(value, validation_func=None):
def check_type(argument, type_of, mro=False, **kwargs):
# if int(py_version) >= 10 and isinstance(type_of, (str, bytes)):
# type_of = eval(type_of, locals(), globals())
if checking_typing_generator(argument, type_of):
# generator will be exhausted when we check it, so we return it without any checking
return argument

if checking_typing_generator(argument, type_of):
# generator will be exhausted when we check it, so we return it without any checking
Expand All @@ -332,8 +335,8 @@ def check_type(argument, type_of, mro=False, **kwargs):
origin, origin_name = get_origins(type_of)
origin_name = origin_name.lower()

if "any" in origin_name or "any" in str(type_of).lower():
return check_result
if "any" in origin_name:
return validate_object(argument, kwargs.get("validation_with"))
if "json" in origin_name or "json" in str(type_of):
return supported_typings["checking_typing_json"](argument, type_of, mro)

Expand Down
2 changes: 1 addition & 1 deletion strongtyping/tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def func_e(a: List[Union[str, int]], b: List[Union[str, int, tuple]]):

def test_with_any():
@match_typing
def func_a(a: Any, b: any):
def func_a(a: Any, b: Any):
return f"{a}-{b}"

assert func_a(2, "2") == "2-2"
Expand Down

0 comments on commit 4e37663

Please sign in to comment.