Skip to content

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
merged 1 commit into from
Dec 18, 2023
Merged

Conversation

rcomer
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

@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
Labels
Documentation: API files in lib/ and doc/api topic: typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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