Skip to content

Commit e4c6cea

Browse files
committed
Use _warn_external for deprecations warnings.
We'll probably switch to _warn_external everywhere at some point, but in the meantime I think deprecations warnings are ones of those that benefit the most from warn_external ("oh, that's the place that needs to be fixed."). Note the internal import to workaround the circular import loop between cbook and cbook.deprecation.
1 parent ef04ad9 commit e4c6cea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/cbook/deprecation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def warn_deprecated(
109109
removal=removal)
110110
category = (PendingDeprecationWarning if pending
111111
else MatplotlibDeprecationWarning)
112-
warnings.warn(message, category, stacklevel=2)
112+
from . import _warn_external
113+
_warn_external(message, category)
113114

114115

115116
def deprecated(since, message='', name='', alternative='', pending=False,
@@ -216,7 +217,8 @@ def finalize(wrapper, new_doc):
216217
else MatplotlibDeprecationWarning)
217218

218219
def wrapper(*args, **kwargs):
219-
warnings.warn(message, category, stacklevel=2)
220+
from . import _warn_external
221+
_warn_external(message, category)
220222
return func(*args, **kwargs)
221223

222224
old_doc = textwrap.dedent(old_doc or '').strip('\n')

0 commit comments

Comments
 (0)