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

Simplify _api.warn_external on Python 3.12+ #28714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Aug 13, 2024

PR summary

Python 3.12 added the skip_file_prefixes argument, which essentially does what this helper function does for us.

Technically, I think the old implementation would set the stack level to the tests, if called in one, but this one doesn't. However, that shouldn't be a problem, as either 1) warnings are errors, or 2), we catch the warning with pytest.warns and don't see the stack level.

PR checklist

@QuLogic QuLogic added this to the v3.10.0 milestone Aug 13, 2024
@QuLogic
Copy link
Member Author

QuLogic commented Aug 13, 2024

Oops, I only tested this with pytest, and not an external file. I accidentally used module names instead of paths, so this didn't work before, but should now with the latest push.

With foo.py as:

import matplotlib.style
import matplotlib.pyplot as plt

matplotlib.style.use({'interactive': True})

fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.margins(tight=False)

this warns as:

/home/elliott/code/matplotlib/foo.py:4: UserWarning: Style includes a parameter, 'interactive', that is not related to style.  Ignoring this parameter.
  matplotlib.style.use({'interactive': True})
/home/elliott/code/matplotlib/foo.py:8: UserWarning: ignoring tight=False in get mode
  ax.margins(tight=False)

@QuLogic QuLogic force-pushed the py312-warning branch 2 times, most recently from 638c0a2 to 3d23708 Compare August 14, 2024 10:02
Python 3.12 added the `skip_file_prefixes` argument, which essentially
does what this helper function does for us.

Technically, I think the old implementation would set the stack level to
the tests, if called in one, but this one doesn't. However, that
shouldn't be a problem, as either 1) warnings are errors, or 2), we
catch the warning with `pytest.warns` and don't see the stack level.
@ksunden ksunden merged commit 843aadd into matplotlib:main Aug 15, 2024
40 checks passed
@QuLogic QuLogic deleted the py312-warning branch August 15, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.