Skip to content

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

@Daverball

Description

@Daverball

Bug summary

Axes.legend is annotated too strictly and incorrectly necessitates Sequence for handles and labels, even though any Iterable works. This also contradicts the docstring on the method.

Code for reproduction

handles, labels = ax.get_legend_handles_labels()
ax.legend(iter(handles), iter(labels))

Actual outcome

No overload variant of "legend" of "Axes" matches argument types "Iterator[Artist]", "Iterator[Any]" [call-overload]

Expected outcome

Passes without type error

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.2

Matplotlib Backend

No response

Python version

3.10

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions