Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 36f2745

Browse filesBrowse files
authored
Merge pull request #23722 from QuLogic/restore-mplDeprecation
Restore deprecation class aliases in cbook
2 parents e913961 + 75a5d7c commit 36f2745
Copy full SHA for 36f2745

File tree

6 files changed

+35
-8
lines changed
Filter options

6 files changed

+35
-8
lines changed

‎doc/api/matplotlib_configuration_api.rst

Copy file name to clipboardExpand all lines: doc/api/matplotlib_configuration_api.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ Colormaps and color sequences
6969
Miscellaneous
7070
=============
7171

72+
.. autoclass:: MatplotlibDeprecationWarning
73+
7274
.. autofunction:: get_cachedir
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Deprecation aliases in cbook
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The module ``matplotlib.cbook.deprecation`` was previously deprecated in
5+
Matplotlib 3.4, along with deprecation-related API in ``matplotlib.cbook``. Due
6+
to technical issues, ``matplotlib.cbook.MatplotlibDeprecationWarning`` and
7+
``matplotlib.cbook.mplDeprecation`` did not raise deprecation warnings on use.
8+
Changes in Python have now made it possible to warn when these aliases are
9+
being used.
10+
11+
In order to avoid downstream breakage, these aliases will now warn, and their
12+
removal has been pushed from 3.6 to 3.8 to give time to notice said warnings.
13+
As replacement, please use `matplotlib.MatplotlibDeprecationWarning`.

‎doc/api/next_api_changes/removals/22514-OG.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/removals/22514-OG.rst
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ Removal of deprecations in ``cbook``
33

44
The module ``cbook.deprecation`` is removed from the public API as it is
55
considered internal. This also holds for deprecation-related re-imports in
6-
``cbook``: ``deprecated``, ``MatplotlibDeprecationWarning``,
7-
``mplDeprecation``, and ``warn_deprecated``.
6+
``cbook``: ``deprecated``, and ``warn_deprecated``.

‎doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst

Copy file name to clipboardExpand all lines: doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ corresponding ``Axes.add_*`` method.
4747
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4848

4949
Historically, it has not been possible to filter
50-
`.MatplotlibDeprecationWarning`\s by checking for `DeprecationWarning`, since we
51-
subclass `UserWarning` directly.
50+
`~matplotlib.MatplotlibDeprecationWarning`\s by checking for
51+
`DeprecationWarning`, since we subclass `UserWarning` directly.
5252

5353
The decision to not subclass `DeprecationWarning` has to do with a decision
5454
from core Python in the 2.x days to not show `DeprecationWarning`\s to users.
5555
However, there is now a more sophisticated filter in place (see
5656
https://www.python.org/dev/peps/pep-0565/).
5757

58-
Users will now see `.MatplotlibDeprecationWarning` only during interactive
59-
sessions, and these can be silenced by the standard mechanism:
58+
Users will now see `~matplotlib.MatplotlibDeprecationWarning` only during
59+
interactive sessions, and these can be silenced by the standard mechanism:
6060

6161
.. code:: python
6262

‎doc/devel/contributing.rst

Copy file name to clipboardExpand all lines: doc/devel/contributing.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ Introducing
322322
1. Announce the deprecation in a new file
323323
:file:`doc/api/next_api_changes/deprecations/99999-ABC.rst` where ``99999``
324324
is the pull request number and ``ABC`` are the contributor's initials.
325-
2. If possible, issue a `.MatplotlibDeprecationWarning` when the deprecated
326-
API is used. There are a number of helper tools for this:
325+
2. If possible, issue a `~matplotlib.MatplotlibDeprecationWarning` when the
326+
deprecated API is used. There are a number of helper tools for this:
327327

328328
- Use ``_api.warn_deprecated()`` for general deprecation warnings
329329
- Use the decorator ``@_api.deprecated`` to deprecate classes, functions,

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
from matplotlib import _api, _c_internal_utils
3131

3232

33+
@_api.caching_module_getattr
34+
class __getattr__:
35+
# module-level deprecations
36+
MatplotlibDeprecationWarning = _api.deprecated(
37+
"3.6", obj_type="",
38+
alternative="matplotlib.MatplotlibDeprecationWarning")(
39+
property(lambda self: _api.deprecation.MatplotlibDeprecationWarning))
40+
mplDeprecation = _api.deprecated(
41+
"3.6", obj_type="",
42+
alternative="matplotlib.MatplotlibDeprecationWarning")(
43+
property(lambda self: _api.deprecation.MatplotlibDeprecationWarning))
44+
45+
3346
def _get_running_interactive_framework():
3447
"""
3548
Return the interactive framework whose event loop is currently running, if

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.