-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow variable stacklevel for deprecation warnings. #6138
Conversation
Each decoration needs to be manually checked, I have ideas on how to make that better, by inspecting the above frames and look whether there is a sentinel asking to add 1 to the stack number, but not tonight. closes scikit-image#6137
Hello @Carreau! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
i like the explicit parameter approach. Adding additional global variables is tricky to get by correct, and I feel like it won't scale well with additional support for other interpreters. i don't have time to read the code now in full but i do think it is an interesting approach. the other thing i would say, i often as a keyword only argument in some of my functions called:
|
@utils.deprecate_kwarg({'max_iter': 'max_num_iter'}, removed_version="1.0", | ||
deprecated_version="0.19") | ||
deprecated_version="0.19", extra_stacklevel=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecated_version="0.19", extra_stacklevel=1) | |
deprecated_version="0.19") |
This is causing the CI failures: extra_stacklevel
is defined for deprecate_kawarg
@@ -208,7 +208,7 @@ def __init__(self, kwarg_mapping, deprecated_version, warning_msg=None, | |||
"for `{func_name}`. ") | |||
if removed_version is not None: | |||
self.warning_msg += (f'It will be removed in ' | |||
f'version {removed_version}.') | |||
f'version {removed_version}. ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thank you 😉
Each decoration needs to be manually checked, I have ideas on how to
make that better, by inspecting the above frames and look whether there
is a sentinel asking to add 1 to the stack number, but not tonight.
closes #6137
Alternative would be to use something like:
And mark corresponding decorators with
__DEPRECATION_SKIP_STACK__ = 1
.or
Which would always compute stacklevels so that deprecation warnings are emitted outside of skimage, potentially with a global toggle for skimage own CI Suite.
Description
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.