You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MatplotlibDeprecationWarning removal hard-breaks seaborn in 3.6rc1 #23716
I don't think we have or easily could have added a warning on importing the class
I agree that this would have been hard! But IMO that puts the burden on matplotlib to deprecate with a bit more care (e.g., proactively searching for usage in downstream libraries, etc.). You are right that this was "properly documented", but it is mentioned in the middle of a very long list of API changes (there are >4000 words on https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.4.0.html). Downstream libraries have the reasonable expectation that they can rely on unit test coverage to surface deprecation warnings, since matplotlib is usually good about that sort of thing.
In the future, please boost the signal of any silent deprecations.
TIL that you can write custom __getattr__ logic at the module-level as of Python 3.7: https://peps.python.org/pep-0562, which I believe is the solution for this sort of problem.
I think that there are other classes which may be in the same situation.
Classes are fine; they can warn with the deprecation decorator. The problem with MatplotlibDeprecationWarning is that it is never instantiated by the user, but only used in except clauses, so it would not trigger any deprecation. The module-level __getattr__ allows warning on access instead.
Activity
tacaswell commentedon Aug 23, 2022
We should put the alias back with a warning for 3.6.
mwaskom commentedon Aug 23, 2022
TIL that you can write custom
__getattr__logic at the module-level as of Python 3.7: https://peps.python.org/pep-0562, which I believe is the solution for this sort of problem.tacaswell commentedon Aug 23, 2022
Yeah, we have a helper using module level
__getattr__specifically for deprecating module level attributes.oscargus commentedon Aug 23, 2022
I guess just importing
MatplotlibDeprecationWarningincbook/__init__.pywould be OK. The problem is to guarantee a warning...I think that there are other classes which may be in the same situation.
Restore deprecation class aliases in cbook
QuLogic commentedon Aug 24, 2022
Classes are fine; they can warn with the deprecation decorator. The problem with
MatplotlibDeprecationWarningis that it is never instantiated by the user, but only used inexceptclauses, so it would not trigger any deprecation. The module-level__getattr__allows warning on access instead.Restore deprecation class aliases in cbook
Restore deprecation class aliases in cbook