Skip to content

MatplotlibDeprecationWarning removal hard-breaks seaborn in 3.6rc1 #23716

Closed

Description

@tacaswell

This removal hard breaks a seaborn function.

Also it's rather unlikely for end users to import MatplotlibDeprecationWarning.

Curious what the basis for this claim was? https://github.com/search?q=%22from+matplotlib.cbook+import+MatplotlibDeprecationWarning%22&type=Code shows 2k+ direct imports of this class, and searching for alternate usage patterns turns up others as well.

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.

Originally posted by @mwaskom in #22514 (comment)

Activity

  1. added this to the v3.6.0 milestone on Aug 23, 2022
  2. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Aug 23, 2022
  3. tacaswell commented on Aug 23, 2022

    @tacaswell
    MemberAuthor

    We should put the alias back with a warning for 3.6.

  4. mwaskom commented on Aug 23, 2022

    @mwaskom

    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.

  5. tacaswell commented on Aug 23, 2022

    @tacaswell
    MemberAuthor

    Yeah, we have a helper using module level __getattr__ specifically for deprecating module level attributes.

  6. oscargus commented on Aug 23, 2022

    @oscargus
    Member

    I guess just importing MatplotlibDeprecationWarning in cbook/__init__.py would be OK. The problem is to guarantee a warning...

    I think that there are other classes which may be in the same situation.

  7. self-assigned this
    on Aug 23, 2022
  8. added a commit that references this issue on Aug 24, 2022
    75a5d7c
  9. QuLogic commented on Aug 24, 2022

    @QuLogic
    Member

    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.

  10. added 2 commits that reference this issue on Apr 19, 2026
    b8d5246
    1202413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions