diff --git a/cadquery/cq.py b/cadquery/cq.py index a97f82140..d788d678a 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -33,6 +33,8 @@ exporters, ) +from .utils import deprecate_kwarg + class CQContext(object): """ @@ -305,6 +307,7 @@ def toOCC(self): return self.objects[0].wrapped + @deprecate_kwarg("centerOption", "ProjectedOrigin") def workplane( self, offset=0.0, invert=False, centerOption="CenterOfMass", origin=None ): diff --git a/cadquery/utils.py b/cadquery/utils.py new file mode 100644 index 000000000..9ced46078 --- /dev/null +++ b/cadquery/utils.py @@ -0,0 +1,26 @@ +from functools import wraps +from inspect import signature +from warnings import warn + + +class deprecate_kwarg: + def __init__(self, name, new_value): + + self.name = name + self.new_value = new_value + + def __call__(self, f): + @wraps(f) + def wrapped(*args, **kwargs): + + f_sig_bound = signature(f).bind(*args, **kwargs) + + if self.name not in f_sig_bound.kwargs: + warn( + f"Default walue of {self.name} will change in next relase to {self.new_value}", + FutureWarning, + ) + + return f(*args, **kwargs) + + return wrapped