TYP: Fix type hints in animation #679
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Actual return is in fact list[list[artist]], which is what mpl.ArtistAnimation actually expects, just the type hints were incorrect
Test case (adapted from tests):
Outputs (formatted for readability):
Note that
_draw_plots
returns a nested list.We (matplotlib) recently introduced type hints (matplotlib/matplotlib#24976), this was discovered in my survey of some of our downstream packages to see how our type hints do.
There are a couple more things that I have flagged that either I have opened or intend to open fixing things on our end, I think there may be some clarifications for the type checker here still even so (though mostly fairly easy e.g. "add a type hint for this variable which the typechecker just sees as Unknown" or "make this list a tuple so the typechecker can validate length and each element type")
We would invite you to test it out early so that you are not surprised when mpl v3.8 is released in a couple months.
If you have any questions or are unsure of how to satisfy the typechecker for mpl related things, feel free to ping me.