Skip to content

Commit

Permalink
RF: Refactor warn_on_args_to_kwargs code and Add warn_on_args_to_kwar…
Browse files Browse the repository at this point in the history
…gs arguments to functions in window.py and actor.py
  • Loading branch information
WassCodeur committed Jun 21, 2024
1 parent f2de303 commit f200ae7
Show file tree
Hide file tree
Showing 17 changed files with 419 additions and 216 deletions.
214 changes: 157 additions & 57 deletions fury/actor.py

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions fury/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def doctest_skip_parser(func):
return func


def warn_on_args_to_kwargs(from_version=None, until_version=None):
def warn_on_args_to_kwargs(from_version="0.1.O", until_version="0.11.0"):
"""Decorator to enforce keyword-only arguments.
This decorator enforces that all arguments after the first one are
Expand Down Expand Up @@ -143,7 +143,7 @@ def wrapper(*args, **kwargs):
params_len = len(params)
try:
return func(*args, **kwargs)
except TypeError:
except TypeError as e:
# if the version of fury is greater than until_version, an error should
# be displayed to indicate that this way of calling the function func
# was supported by from_version until_version but not by the current
Expand All @@ -152,13 +152,7 @@ def wrapper(*args, **kwargs):
from fury import __version__ as FURY_VERSION

if version.parse(FURY_VERSION) > version.parse(until_version):
raise RuntimeError(
f"Calling the {func.__name__} function in this way "
f"was supported from {from_version} up to {until_version}, "
f"but not in the current version of FURY {FURY_VERSION}. "
f"Here's how you must call the Function {func.__name__}: "
f"{func.__name__}({func_params_sample})"
) from None
raise TypeError(e) from e

if ARG_DEFAULT:
missing_kwargs += ARG_DEFAULT
Expand Down
2 changes: 1 addition & 1 deletion fury/shaders/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_add_shader_callback():
scene = window.Scene()
scene.add(cube)

showm = window.ShowManager(scene)
showm = window.ShowManager(scene=scene)

class Timer:
idx = 0.0
Expand Down
Loading

0 comments on commit f200ae7

Please sign in to comment.