From abb5d4ad7795b81b572bbb5c7fd08254e0beebb4 Mon Sep 17 00:00:00 2001 From: AttAditya Date: Tue, 19 May 2026 22:22:40 +0530 Subject: [PATCH 1/2] fix: Callable Matching Issue --- langex/utils/matcher.py | 2 +- tests/functions/test_validations.py | 90 +++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/functions/test_validations.py diff --git a/langex/utils/matcher.py b/langex/utils/matcher.py index 2bb5069..dcd4cc7 100644 --- a/langex/utils/matcher.py +++ b/langex/utils/matcher.py @@ -41,7 +41,7 @@ def handle_callable( ) -> None: if result.evaluated(): return if args.arg_type != callable: return - return callable(args.received_arg) + result.evaluate(callable(args.received_arg)) def handle_langex_class( result: _MatchResult, args: _MatchArgs diff --git a/tests/functions/test_validations.py b/tests/functions/test_validations.py new file mode 100644 index 0000000..d133f7e --- /dev/null +++ b/tests/functions/test_validations.py @@ -0,0 +1,90 @@ +from langex.core.errors import ValidationError +from langex.core.functions import args_required, returns +from langex.core.testing import discover_test, expects + +@args_required(int) +def func(arg): + return 0 + +@args_required(str) +def func2(arg): + return 0 + +@args_required(float) +def func3(arg): + return 0 + +@args_required(bool) +def func4(arg): + return 0 + +@args_required(callable) +def func5(arg): + return 0 + +@returns(int) +def func6(): + return 0 + +@returns(str) +def func7(): + return "0" + +@returns(float) +def func8(): + return 0.0 + +@returns(bool) +def func9(): + return False + +@returns(callable) +def func10(): + return lambda: None + +@returns(int) +def func11(): + return "0" + +@returns(str) +def func12(): + return 0 + +@returns(float) +def func13(): + return "0" + +@returns(bool) +def func14(): + return "0" + +@returns(callable) +def func15(): + return "0" + +@discover_test +def test_arg_validations(): + (lambda: func(1) ) @expects (0) + (lambda: func2("1") ) @expects (0) + (lambda: func3(0.0) ) @expects (0) + (lambda: func4(True) ) @expects (0) + (lambda: func5(lambda: None)) @expects (0) + (lambda: func("1") ) @expects (ValidationError) + (lambda: func2(1) ) @expects (ValidationError) + (lambda: func3(0) ) @expects (ValidationError) + (lambda: func4(1) ) @expects (ValidationError) + (lambda: func5(1) ) @expects (ValidationError) + +@discover_test +def test_return_validations(): + (lambda: func6() ) @expects (0) + (lambda: func7() ) @expects ("0") + (lambda: func8() ) @expects (0.0) + (lambda: func9() ) @expects (False) + (lambda: callable(func10())) @expects (True) + (lambda: func11() ) @expects (ValidationError) + (lambda: func12() ) @expects (ValidationError) + (lambda: func13() ) @expects (ValidationError) + (lambda: func14() ) @expects (ValidationError) + (lambda: func15() ) @expects (ValidationError) + From ebb9e46c480ab6323ebde4b64461487a2b22e486 Mon Sep 17 00:00:00 2001 From: AttAditya Date: Tue, 19 May 2026 22:24:40 +0530 Subject: [PATCH 2/2] bump: v0.4.5 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7dc705b..dcfd789 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "langex" -version = "0.4.4" +version = "0.4.5" description = "Runtime language extensions and validation tools for Python" readme = "README.md" license = { file = "LICENSE" }