decorators
#
Decorators for FURY tests.
Compiled regular expression object. |
|
|
Decorator replaces custom skip test markup in doctests. |
|
Decorator to enforce keyword-only arguments. |
SKIP_RE#
- fury.decorators.SKIP_RE()#
Compiled regular expression object.
doctest_skip_parser#
- fury.decorators.doctest_skip_parser(func)[source]#
Decorator replaces custom skip test markup in doctests.
Say a function has a docstring:
something # skip if not HAVE_AMODULE something + else something # skip if HAVE_BMODULE
This decorator will evaluate the expression after
skip if
. If this evaluates to True, then the comment is replaced by# doctest: +SKIP
. If False, then the comment is just removed. The expression is evaluated in theglobals
scope of func. For example, if the module globalHAVE_AMODULE
is False, and module globalHAVE_BMODULE
is False, the returned function will have docstring:something # doctest: +SKIP something + else something
warn_on_args_to_kwargs#
- fury.decorators.warn_on_args_to_kwargs(from_version='0.11.0', until_version='0.14.0')[source]#
Decorator to enforce keyword-only arguments.
This decorator enforces that all arguments after the first one are keyword-only arguments. It also checks that all keyword arguments are expected by the function.
- Parameters:
- Returns:
decorator – Decorator function.
- Return type:
Callable
Examples
>>> from fury.decorators import warn_on_args_to_kwargs >>> import fury >>> @warn_on_args_to_kwargs() ... def f(a, b, *, c, d=1, e=1): ... return a + b + c + d + e >>> CURRENT_VERSION = fury.__version__ >>> fury.__version__ = "0.11.0" >>> f(1, 2, 3, 4, 5) 15 >>> f(1, 2, c=3, d=4, e=5) 15 >>> f(1, 2, 2, 4, e=5) 14 >>> f(1, 2, c=3, d=4) 11 >>> f(1, 2, d=3, e=5) Traceback (most recent call last): ... TypeError: f() missing 1 required keyword-only argument: 'c'