From 3744f0ca8ffd93fbca3526d28d5d9de68a646ace Mon Sep 17 00:00:00 2001 From: Alex Fernandez Luces Date: Tue, 21 Oct 2025 11:32:55 +0200 Subject: [PATCH 1/5] fix: Decorator order issue --- .../geometry/core/connection/launcher.py | 12 +++----- tests/test_misc_checks.py | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/ansys/geometry/core/connection/launcher.py b/src/ansys/geometry/core/connection/launcher.py index 8bcd601df6..fd53b5e67e 100644 --- a/src/ansys/geometry/core/connection/launcher.py +++ b/src/ansys/geometry/core/connection/launcher.py @@ -496,9 +496,8 @@ def launch_modeler_with_spaceclaim_and_pimlight( client_log_file=client_log_file, ) - -@kwargs_passed_not_accepted @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") +@kwargs_passed_not_accepted def launch_modeler_with_geometry_service( version: str | int | None = None, host: str = "localhost", @@ -619,9 +618,8 @@ def launch_modeler_with_geometry_service( product_version=product_version, ) - -@kwargs_passed_not_accepted @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") +@kwargs_passed_not_accepted def launch_modeler_with_discovery( version: str | int | None = None, host: str = "localhost", @@ -740,9 +738,8 @@ def launch_modeler_with_discovery( product_version=product_version, ) - -@kwargs_passed_not_accepted @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") +@kwargs_passed_not_accepted def launch_modeler_with_spaceclaim( version: str | int | None = None, host: str = "localhost", @@ -861,9 +858,8 @@ def launch_modeler_with_spaceclaim( product_version=product_version, ) - -@kwargs_passed_not_accepted @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") +@kwargs_passed_not_accepted def launch_modeler_with_core_service( version: str | int | None = None, host: str = "localhost", diff --git a/tests/test_misc_checks.py b/tests/test_misc_checks.py index 09f13fcbbf..c13f0c5ce5 100644 --- a/tests/test_misc_checks.py +++ b/tests/test_misc_checks.py @@ -439,3 +439,32 @@ def my_method(arg1, arg2, **kwargs): match="The following keyword arguments are not accepted in the method 'my_method': arg3.", ): my_method(arg1=1, arg2=2, arg3=3) + + +# TODO: This test fails, fix decorator +# def test_kwargs_passed_not_accepted_decorator_order(): +# """Test the kwargs_passed_not_accepted decorator.""" + +# @kwargs_passed_not_accepted +# @deprecated_argument("arg3") +# def my_method(arg1, arg2, **kwargs): +# """A method that accepts no keyword arguments.""" +# return arg1 + arg2 + +# # Call the method without kwargs - should not raise an error +# assert my_method(1, 2) == 3 +# assert my_method(arg1=1, arg2=2) == 3 + +# # Call the method with kwargs - should raise an error +# with pytest.raises( +# TypeError, +# match="The following keyword arguments are not accepted in the" +# " method 'my_method': unexpected_arg, another_one.", +# ): +# my_method(1, 2, unexpected_arg=3, another_one="test") + +# with pytest.raises( +# TypeError, +# match="The following keyword arguments are not accepted in the method 'my_method': arg3.", +# ): +# my_method(arg1=1, arg2=2, arg3=3) \ No newline at end of file From 9f5cc4619dbd0eae6afbd777aab9de229ca4b66a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:34:00 +0000 Subject: [PATCH 2/5] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/connection/launcher.py | 4 ++++ tests/test_misc_checks.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/connection/launcher.py b/src/ansys/geometry/core/connection/launcher.py index fd53b5e67e..e41d562fdd 100644 --- a/src/ansys/geometry/core/connection/launcher.py +++ b/src/ansys/geometry/core/connection/launcher.py @@ -496,6 +496,7 @@ def launch_modeler_with_spaceclaim_and_pimlight( client_log_file=client_log_file, ) + @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") @kwargs_passed_not_accepted def launch_modeler_with_geometry_service( @@ -618,6 +619,7 @@ def launch_modeler_with_geometry_service( product_version=product_version, ) + @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") @kwargs_passed_not_accepted def launch_modeler_with_discovery( @@ -738,6 +740,7 @@ def launch_modeler_with_discovery( product_version=product_version, ) + @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") @kwargs_passed_not_accepted def launch_modeler_with_spaceclaim( @@ -858,6 +861,7 @@ def launch_modeler_with_spaceclaim( product_version=product_version, ) + @deprecated_argument("product_version", "version", version="0.10.8", remove="0.13.0") @kwargs_passed_not_accepted def launch_modeler_with_core_service( diff --git a/tests/test_misc_checks.py b/tests/test_misc_checks.py index c13f0c5ce5..3486230724 100644 --- a/tests/test_misc_checks.py +++ b/tests/test_misc_checks.py @@ -467,4 +467,4 @@ def my_method(arg1, arg2, **kwargs): # TypeError, # match="The following keyword arguments are not accepted in the method 'my_method': arg3.", # ): -# my_method(arg1=1, arg2=2, arg3=3) \ No newline at end of file +# my_method(arg1=1, arg2=2, arg3=3) From 8a43aae8fa62b0aa1e350a7499e155b532171ccc Mon Sep 17 00:00:00 2001 From: Alex Fernandez Luces Date: Tue, 21 Oct 2025 11:34:56 +0200 Subject: [PATCH 3/5] fix: Add test --- tests/test_misc_checks.py | 60 +++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/test_misc_checks.py b/tests/test_misc_checks.py index c13f0c5ce5..671d678085 100644 --- a/tests/test_misc_checks.py +++ b/tests/test_misc_checks.py @@ -441,30 +441,36 @@ def my_method(arg1, arg2, **kwargs): my_method(arg1=1, arg2=2, arg3=3) -# TODO: This test fails, fix decorator -# def test_kwargs_passed_not_accepted_decorator_order(): -# """Test the kwargs_passed_not_accepted decorator.""" - -# @kwargs_passed_not_accepted -# @deprecated_argument("arg3") -# def my_method(arg1, arg2, **kwargs): -# """A method that accepts no keyword arguments.""" -# return arg1 + arg2 - -# # Call the method without kwargs - should not raise an error -# assert my_method(1, 2) == 3 -# assert my_method(arg1=1, arg2=2) == 3 - -# # Call the method with kwargs - should raise an error -# with pytest.raises( -# TypeError, -# match="The following keyword arguments are not accepted in the" -# " method 'my_method': unexpected_arg, another_one.", -# ): -# my_method(1, 2, unexpected_arg=3, another_one="test") - -# with pytest.raises( -# TypeError, -# match="The following keyword arguments are not accepted in the method 'my_method': arg3.", -# ): -# my_method(arg1=1, arg2=2, arg3=3) \ No newline at end of file +def test_kwargs_passed_not_accepted_decorator_order(): + """Test the kwargs_passed_not_accepted decorator.""" + + @deprecated_argument("arg3") + @kwargs_passed_not_accepted + def my_method(arg1, arg2, **kwargs): + """A method that accepts no keyword arguments.""" + return arg1 + arg2 + + # Call the method without kwargs - should not raise an error + assert my_method(1, 2) == 3 + assert my_method(arg1=1, arg2=2) == 3 + + # Call the method with kwargs - should raise an error + with pytest.raises( + TypeError, + match="The following keyword arguments are not accepted in the" + " method 'my_method': unexpected_arg, another_one.", + ): + my_method(1, 2, unexpected_arg=3, another_one="test") + + with pytest.raises( + TypeError, + match="The following keyword arguments are not accepted in the method 'my_method': arg3.", + ): + my_method(arg1=1, arg2=2, arg3=3) + + # TODO: This test fails, fix decorator + # @kwargs_passed_not_accepted + # @deprecated_argument("arg3") + # def my_method(arg1, arg2, **kwargs): + # """A method that accepts no keyword arguments.""" + # return arg1 + arg2 From 75c64ef13eac66c13bb2da1e86beb86c0fd5feb1 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:35:37 +0000 Subject: [PATCH 4/5] chore: adding changelog file 2337.fixed.md [dependabot-skip] --- doc/changelog.d/2337.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/2337.fixed.md diff --git a/doc/changelog.d/2337.fixed.md b/doc/changelog.d/2337.fixed.md new file mode 100644 index 0000000000..1145b6db25 --- /dev/null +++ b/doc/changelog.d/2337.fixed.md @@ -0,0 +1 @@ +Decorator order issue From b5b5d714d3aa3d068ac26fe7f01c08e1b992000c Mon Sep 17 00:00:00 2001 From: Alex Fernandez Luces Date: Tue, 21 Oct 2025 11:55:37 +0200 Subject: [PATCH 5/5] fix: Link issue to TODO --- tests/test_misc_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_misc_checks.py b/tests/test_misc_checks.py index 671d678085..c2e6d5f436 100644 --- a/tests/test_misc_checks.py +++ b/tests/test_misc_checks.py @@ -468,7 +468,7 @@ def my_method(arg1, arg2, **kwargs): ): my_method(arg1=1, arg2=2, arg3=3) - # TODO: This test fails, fix decorator + # TODO: This test fails, fix decorator #2338 # @kwargs_passed_not_accepted # @deprecated_argument("arg3") # def my_method(arg1, arg2, **kwargs):