-
-
Notifications
You must be signed in to change notification settings - Fork 25.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
[MRG] Replace DeprecationWarning with FutureWarning #15080
[MRG] Replace DeprecationWarning with FutureWarning #15080
Conversation
Is it good to name it the same as Numpy? Shouldn't we have a SKLVisibleDeprecationWarning or something like that? |
I was hoping that users could ignore both ours and numpy's with a simple 'VisibleDeprecationWarning' regex but that doesn't seem to be possible anyway (maybe for the better). I'll change to SklearnDeprecationWarning |
@adrinjalali you were thinking about warnigns ;) |
I'm wondering why we do
The unless triggered by code in On the other hand, we have:
And:
IMO most I'm in favor of using Packages who depend on Also, we wan move a bunch of our |
I agree our DeprecationWarnings should probably have been FutureWarnings in the first place. I'm OK for switching to FutureWarnings. However I don't think we want to worry about PendingFutureWarnings (at least for now, and definitely not for this PR, let's keep things simple). Same for DeprecationWarning: these are for Python developers, not for library users/maintainers. I don't think we should ever mess with those. |
+1 for using Related discussions in numpy/numpy#8829 (comment) and scikit-image/scikit-image#3244 |
+1 for |
Why shouldn't we? |
The options are:
Is the "deprecated in 0.22" actionable information? I am going under the assumption that "no one reads warnings", so making the warning only include actionable information is a little nicer. "Remove in 0.24" -> better do something about this before 0.24. |
I have no idea why that joblib warning is showing up :/ https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=9548 |
@jeremiedbb or @ogrisel maybe? |
It's green \o/ |
@@ -25,10 +24,6 @@ | |||
logger.setLevel(logging.INFO) | |||
|
|||
|
|||
# Make sure that DeprecationWarning within this package always gets printed | |||
warnings.filterwarnings('always', category=DeprecationWarning, | |||
module=r'^{0}\.'.format(re.escape(__name__))) |
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.
Note: the main purpose of this PR is to remove this filter
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.
I'll be happy to merge soon if there are no objections. Before there are more conflicts and issues.
Could you please add a nice whats_new for this one? I think it's missing it. |
Just pushed something but I think we can have a better message |
Thanks for the reviews!! \o/ |
I noticed PEP 565 says:
|
In the same section Additional use case for FutureWarning in the PEP 565 it states:
In the end I think we want the warning to be shown by default to users in the following situation: # my_module.py
import warnings
def hello():
warnings.warn("Deprecated", DeprecationWarning) # main.py
from my_module import hello
hello() and running |
closes #9857
This PR replaces
DeprecationWarning
with a newly createdSklearnDeprecationWarning
(similar to numpy'sVisibleDeprecationWarning
).This fixes the custom filter issue raised in #9857 (custom filter are bad basically)
The downside is that users who are already ignoring the
DeprecationWarning
will need to change their code to now ignore theSklearnDeprecationWarning
.There's no backward compatibility guarantee regarding warnings, but if this PR gets merged, we should make sure to let users know as much as possible
Also we should give an update on this SO question
EDIT: changed name from
VisibleDeprecationWarning
toSklearnDeprecationWarning
EDIT: changed again to raise
FutureWarning