21 __all__ = [
"deprecate_policy"]
29 """Issue a deprecation warning if one of the supplied arguments 30 is a Policy, and convert that to a PropertySet. 34 policy_args : `~collections.abc.Sequence`, optional 35 Known positions of likely `~lsst.pex.Policy` arguments for the wrapped 36 function. Can be out of range since some pybind11 constructors take 37 different numbers of arguments. If `None` all arguments will be 41 @functools.wraps(func)
42 def internal(*args, **kwargs):
45 if policy_args
is None:
47 args_to_check = range(len(args))
49 max_i = len(newargs) - 1
50 args_to_check = [p
for p
in policy_args
if p <= max_i]
52 for i
in args_to_check:
54 if isinstance(a, Policy):
55 warnings.warn(f
"pexPolicy in argument {i} is deprecated. Replace with PropertySet" 56 " (Policy support will be removed in v19)",
57 FutureWarning, stacklevel=2)
60 return func(*newargs, **kwargs)
def deprecate_policy(func, policy_args=None)