Skip to content

Use _warn_external for deprecations warnings.#12152

Merged
jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:external-deprecation-warnings
Sep 18, 2018
Merged

Use _warn_external for deprecations warnings.#12152
jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:external-deprecation-warnings

Conversation

@anntzer

@anntzer anntzer commented Sep 18, 2018

Copy link
Copy Markdown
Contributor

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.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak

jklymak commented Sep 18, 2018

Copy link
Copy Markdown
Member

Why will we switch to _warn_external?

@anntzer

anntzer commented Sep 18, 2018

Copy link
Copy Markdown
Contributor Author

#11298 but the TLDR is that given an example such as

from matplotlib import pyplot as plt

plt.plot([[1, 2], [3, 4]], [[1, 2, 3], [4, 5, 6]])
plt.show()

currently the warning displayed is

/home/antony/src/extern/matplotlib/lib/matplotlib/axes/_base.py:377: MatplotlibDeprecationWarning: 
cycling among columns of inputs with non-matching shapes is deprecated.
  cbook.warn_deprecated("2.2", "cycling among columns of inputs "

but with the PR the warning becomes

/tmp/test.py:3: MatplotlibDeprecationWarning: 
cycling among columns of inputs with non-matching shapes is deprecated.
  plt.plot([[1, 2], [3, 4]], [[1, 2, 3], [4, 5, 6]])

which is quite a bit more helpful in pointing out what needs to be fixed...

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.
@anntzer anntzer force-pushed the external-deprecation-warnings branch from e4c6cea to f21ad20 Compare September 18, 2018 14:41
@jklymak jklymak added this to the v3.1 milestone Sep 18, 2018
@jklymak jklymak merged commit 0cce49b into matplotlib:master Sep 18, 2018
@anntzer anntzer deleted the external-deprecation-warnings branch September 18, 2018 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants