diff --git a/lib/matplotlib/cbook/deprecation.py b/lib/matplotlib/cbook/deprecation.py index 9c8c83225ba7..2df87d17e187 100644 --- a/lib/matplotlib/cbook/deprecation.py +++ b/lib/matplotlib/cbook/deprecation.py @@ -75,7 +75,7 @@ def warn_deprecated( pending : bool, optional If True, uses a PendingDeprecationWarning instead of a - DeprecationWarning. + MatplotlibDeprecationWarning. removal : str, optional The expected removal version. With the default (an empty string), a @@ -100,7 +100,8 @@ def warn_deprecated( """ message = _generate_deprecation_message( since, message, name, alternative, pending, obj_type, removal=removal) - warnings.warn(message, mplDeprecation, stacklevel=2) + warn_cls = PendingDeprecationWarning if pending else mplDeprecation + warnings.warn(message, warn_cls, stacklevel=2) def deprecated(since, message='', name='', alternative='', pending=False, @@ -140,7 +141,7 @@ def new_function(): pending : bool, optional If True, uses a PendingDeprecationWarning instead of a - DeprecationWarning. + MatplotlibDeprecationWarning. removal : str, optional The expected removal version. With the default (an empty string), a @@ -205,7 +206,8 @@ def finalize(wrapper, new_doc): removal=removal) def wrapper(*args, **kwargs): - warnings.warn(message, mplDeprecation, stacklevel=2) + warn_cls = PendingDeprecationWarning if pending else mplDeprecation + warnings.warn(message, warn_cls, stacklevel=2) return func(*args, **kwargs) old_doc = textwrap.dedent(old_doc or '').strip('\n')