Skip to content

Add typing to pyplot.show() to avoid errors with mypy --strict. #26940

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
Oct 4, 2023

Conversation

hhoppe
Copy link
Contributor

@hhoppe hhoppe commented Sep 27, 2023

Add type signature for pyplot.show.

PR summary

This is done to prevent errors when mypy --strict is invoked on client code containing plt.show().
Closes #26919.
The signature indicates a return type of None, which matches the matplotlib documentation, even though the implementation could actually return non-None if the back-end function does.

PR checklist

Added type signature for `show`.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@ksunden
Copy link
Member

ksunden commented Sep 27, 2023

I could argue to do the same/similar to draw_if_interactive and new_figure_manager (the latter would return a FigureManagerBase (which is already imported)).

@hhoppe
Copy link
Contributor Author

hhoppe commented Sep 28, 2023 via email

@oscargus oscargus added this to the v3.8.1 milestone Sep 28, 2023
@timhoffm timhoffm merged commit 6ba7d5f into matplotlib:main Oct 4, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 4, 2023
QuLogic added a commit that referenced this pull request Oct 5, 2023
…940-on-v3.8.x

Backport PR #26940 on branch v3.8.x (Add typing to pyplot.show() to avoid errors with mypy --strict.)
@hhoppe hhoppe deleted the hhoppe-patch-1 branch October 10, 2023 18:20
@ksunden ksunden mentioned this pull request Nov 2, 2023
5 tasks
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.

[Bug]: Missing file pyplot.pyi for mypy typing
4 participants