-
-
Notifications
You must be signed in to change notification settings - Fork 477
feat: Respect user warning filters for deprecation messages #2853
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
Conversation
i dont think this deserve a changelog |
Hold on, does the default behavior make the deprecation warnings visible? |
According to a quick research, no. Users would've to opt-in |
Would it be possible for pycord to make it opt out instead without forcing them |
I think that's what |
I didn't test it yet, I'll test this tonight |
after testing, its working great without those 2 lines, we can easily ignore those warning globally or within a with .. |
So the default configuration used by python does work? |
The default one does raise the warning, so we don't need to add any 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.
Fine with me then
Do you have some docs / other ref about the default behaviour ? |
https://docs.python.org/3/library/warnings.html but its mainly about the filters, there is no need to add a filter here since we are not filtering anything but emitting a warn |
Summary
This PR removes the calls to
warnings.simplefilter("always", DeprecationWarning)
andwarnings.simplefilter("default", DeprecationWarning)
in the deprecation helper.Currently, the implementation forces DeprecationWarning visibility by temporarily setting the filter to "always", and then resets it to "default". This overrides user-defined warning filters, which is not ideal.
With this change, the function simply calls warnings.warn, leaving all filtering behavior up to the user or their framework (e.g. pytest, PYTHONWARNINGS, warnings.filterwarnings).
Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.