Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2337.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Decorator order issue
8 changes: 4 additions & 4 deletions src/ansys/geometry/core/connection/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ def launch_modeler_with_spaceclaim_and_pimlight(
)


@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",
Expand Down Expand Up @@ -620,8 +620,8 @@ def launch_modeler_with_geometry_service(
)


@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",
Expand Down Expand Up @@ -741,8 +741,8 @@ def launch_modeler_with_discovery(
)


@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",
Expand Down Expand Up @@ -862,8 +862,8 @@ def launch_modeler_with_spaceclaim(
)


@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",
Expand Down
35 changes: 35 additions & 0 deletions tests/test_misc_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,38 @@ 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)


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 #2338
# @kwargs_passed_not_accepted
# @deprecated_argument("arg3")
# def my_method(arg1, arg2, **kwargs):
# """A method that accepts no keyword arguments."""
# return arg1 + arg2
Loading