-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn about upcoming change of the centerOption (#313)
* Added deprecate_kwarg decorator * Added warning related to default centerOption deprecation
- Loading branch information
1 parent
d17d27d
commit 6ecb0fc
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |