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

Sign up
Appearance settings

Update ax.legend input types #27535

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
oscargus merged 1 commit into matplotlib:main from rcomer:legend-argtypes
Dec 18, 2023
Merged

Conversation

Copy link
Member

@rcomer rcomer commented Dec 17, 2023

PR summary

Closes #27507 by changing the annotations for handles and labels to Iterable, as requested. In addition to the discussion there, I just realised we already have it like this for fig.legend

def legend(self, handles: Iterable[Artist], labels: Iterable[str], **kwargs) -> Legend: ...
@overload
def legend(self, *, handles: Iterable[Artist], **kwargs) -> Legend: ...
@overload
def legend(self, labels: Iterable[str], **kwargs) -> Legend: ...

Also changes the handles type to list in the ax.legend docstring, following the guidelines. This is now consistent with the labels type in this docstring and with the fig.legend docstring.

PR checklist

Daverball reacted with heart emoji
@rcomer rcomer added topic: typing Documentation: API files in lib/ and doc/api labels Dec 17, 2023
@rcomer rcomer added this to the v3.8.3 milestone Dec 17, 2023
@rcomer rcomer changed the title (削除) Update legend input types (削除ここまで) (追記) Update ax.legend input types (追記ここまで) Dec 17, 2023
@oscargus oscargus merged commit 09069b1 into matplotlib:main Dec 18, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 18, 2023
@rcomer rcomer deleted the legend-argtypes branch December 18, 2023 11:15
ksunden added a commit that referenced this pull request Dec 18, 2023
...535-on-v3.8.x
Backport PR #27535 on branch v3.8.x (Update ax.legend input types)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@timhoffm timhoffm timhoffm approved these changes

Assignees
No one assigned
Labels
Documentation: API files in lib/ and doc/api topic: typing
Projects
None yet
Milestone
v3.8.3
Development

Successfully merging this pull request may close these issues.

[Bug]: Argument types for handles and labels are too strict for method Axes.legend

AltStyle によって変換されたページ (->オリジナル) /