TYP: Fix some Legend-related typing#32111
Open
QuLogic wants to merge 3 commits into
Open
Conversation
Namely, 1) add a `Protocol` for `HandlerPatch's callable, as default arguments cannot be represented by plain `Callable`; 2) propagate kwargs for `__init__` with a `TypedDict` (but note that I manually typed kwargs for `HandlerNpoints` subclasses as `TypedDict` entries are not allowed to duplicate explicit kwargs and many of them have at least one); 3) add a few missed parameter types.
The input to `Artist.set_label` is cast to a `str` immediately (unless `None`) when saved, so getting it is always `str`, not `object`.
It takes any `Artist` and `list` is invariant, so switch `Sequence`.
timhoffm
reviewed
Jul 24, 2026
| def get_tick_padding(self) -> float: ... | ||
| def get_gridlines(self) -> list[Line2D]: ... | ||
| def get_label(self) -> Text: ... | ||
| def get_label(self) -> Text: ... # type: ignore[override] |
Member
There was a problem hiding this comment.
On a side note, this inconsistent use of label is discussed in #29422.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR summary
Specifically, type the rest of
legend_handler.pyi, and fix types forArtist.get_labelandPackerBase.__init__.AI Disclosure
None
PR checklist