Skip to content
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

Add typing to test_plot.py #8889

Merged
merged 20 commits into from
Apr 5, 2024
Merged

Add typing to test_plot.py #8889

merged 20 commits into from
Apr 5, 2024

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Mar 29, 2024

Enforce typing on all tests in test_plot.py and add the remaining type hints.

# nb. this function also matches meshes from pcolormesh
return plt.gcf().findobj(mpl.collections.QuadMesh)
return plt.gcf().findobj(mpl.collections.QuadMesh) # type: ignore[return-value] # mpl error?
Copy link
Contributor Author

@Illviljan Illviljan Mar 29, 2024

Choose a reason for hiding this comment

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

I believe the typing for findobj is wrong. Looks to me it mostly returns the same type as the input.
https://github.com/matplotlib/matplotlib/blob/78b6bdc04f89dafe4d157855a9023826cab8a0fd/lib/matplotlib/artist.pyi#L131-L135
Probably should be something like TypeVar("T_Artist", bound=Artist).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @ksunden if you're still interested.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thank you @ksunden !

xarray/tests/test_plot.py Outdated Show resolved Hide resolved
@Illviljan Illviljan marked this pull request as ready for review March 29, 2024 12:42
@Illviljan Illviljan added the plan to merge Final call for comments label Apr 5, 2024
@dcherian dcherian merged commit 5bcbf70 into pydata:main Apr 5, 2024
31 checks passed
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