Skip to content
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

transform MW deprecation warnings into python DeprecationWarning #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DylannCordel
Copy link
Contributor

Try to avoid fake warnings which are just deprecation warnings to keep logs cleans and usefull

@danmichaelo
Copy link
Member

Sorry about the very late response! As for the None check, best practice is to use "is not None":

https://docs.quantifiedcode.com/python-anti-patterns/readability/comparison_to_none.html#compare-values-to-none-using-the-pattern-if-cond-is-none

Overall, I'm a little bit reluctant about this PR. The deprecation warnings from the API are really warnings in the true sense, as they warn you about something you need to address to avoid the code from breaking in the future. Esp. for scripts that rarely needs to be touched, a sudden rise of warnings can be a good reminder about the existence of the script, and that something needs to be done with it at some point :)

Warnings from the warnings module are often easier to miss. But that can be addressed with logging.captureWarnings:

https://docs.python.org/2/library/logging.html#logging.captureWarnings

So perhaps a compromise could be to merge this PR, but mention in the documentation that logging.captureWarnings(true) can be used to log deprecation warnings from the API? Any thoughts on this, @waldyrious ?

In any case, I would prefer to remove the wording "fake warnings" ;)

@waldyrious
Copy link
Member

Any thoughts on this, @waldyrious ?

I never really user mwclient as a library in another project (I only made quick scripts here and there, back when I dabbled a little with Python), so I don't think I'm qualified to comment on the signal-to-noise ratio of deprecation warnings.

On principle, I do agree with what you say above:

The deprecation warnings from the API are really warnings in the true sense, as they warn you about something you need to address to avoid the code from breaking in the future.

So my inclination, for what it's worth, would be to have deprecation warnings shown by default in the output.

@DylannCordel
Copy link
Contributor Author

Hi guys,

Some news about this PR ?

This commit does not disable the "deprecated messages" from the logs but transforms those into a real DeprecationWarning. Those ones can be displayed or not in the console depending the logging configuration.

@AdamWill
Copy link
Member

AdamWill commented Jul 5, 2023

I don't have a really strong opinion on it either way, personally...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants