FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #23722 on branch v3.6.x (Restore deprecation class aliases in cbook) by meeseeksmachine · Pull Request #23728 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (5) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions doc/api/matplotlib_configuration_api.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ Colormaps and color sequences
Miscellaneous
=============

.. autoclass:: MatplotlibDeprecationWarning

.. autofunction:: get_cachedir
13 changes: 13 additions & 0 deletions doc/api/next_api_changes/deprecations/23720-RS.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Deprecation aliases in cbook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The module ``matplotlib.cbook.deprecation`` was previously deprecated in
Matplotlib 3.4, along with deprecation-related API in ``matplotlib.cbook``. Due
to technical issues, ``matplotlib.cbook.MatplotlibDeprecationWarning`` and
``matplotlib.cbook.mplDeprecation`` did not raise deprecation warnings on use.
Changes in Python have now made it possible to warn when these aliases are
being used.

In order to avoid downstream breakage, these aliases will now warn, and their
removal has been pushed from 3.6 to 3.8 to give time to notice said warnings.
As replacement, please use `matplotlib.MatplotlibDeprecationWarning`.
3 changes: 1 addition & 2 deletions doc/api/next_api_changes/removals/22514-OG.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ Removal of deprecations in ``cbook``

The module ``cbook.deprecation`` is removed from the public API as it is
considered internal. This also holds for deprecation-related re-imports in
``cbook``: ``deprecated``, ``MatplotlibDeprecationWarning``,
``mplDeprecation``, and ``warn_deprecated``.
``cbook``: ``deprecated``, and ``warn_deprecated``.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ corresponding ``Axes.add_*`` method.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

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

.. code:: python

Expand Down
4 changes: 2 additions & 2 deletions doc/devel/contributing.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ Introducing
1. Announce the deprecation in a new file
:file:`doc/api/next_api_changes/deprecations/99999-ABC.rst` where ``99999``
is the pull request number and ``ABC`` are the contributor's initials.
2. If possible, issue a `.MatplotlibDeprecationWarning` when the deprecated
API is used. There are a number of helper tools for this:
2. If possible, issue a `~matplotlib.MatplotlibDeprecationWarning` when the
deprecated API is used. There are a number of helper tools for this:

- Use ``_api.warn_deprecated()`` for general deprecation warnings
- Use the decorator ``@_api.deprecated`` to deprecate classes, functions,
Expand Down
13 changes: 13 additions & 0 deletions lib/matplotlib/cbook/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
from matplotlib import _api, _c_internal_utils


@_api.caching_module_getattr
class __getattr__:
# module-level deprecations
MatplotlibDeprecationWarning = _api.deprecated(
"3.6", obj_type="",
alternative="matplotlib.MatplotlibDeprecationWarning")(
property(lambda self: _api.deprecation.MatplotlibDeprecationWarning))
mplDeprecation = _api.deprecated(
"3.6", obj_type="",
alternative="matplotlib.MatplotlibDeprecationWarning")(
property(lambda self: _api.deprecation.MatplotlibDeprecationWarning))


def _get_running_interactive_framework():
"""
Return the interactive framework whose event loop is currently running, if
Expand Down

Back | FazBrowse Home | New Git URL