Title: [Bug]: Argument types for `handles` and `labels` are too strict for method `Axes.legend` · Issue #27507 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Argument types for `handles` and `labels` are too strict for method `Axes.legend` · Issue #27507 · matplotlib/matplotlib
X Title: [Bug]: Argument types for `handles` and `labels` are too strict for method `Axes.legend` · Issue #27507 · matplotlib/matplotlib
Description: 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...
Open Graph Description: 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. Co...
X Description: 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. Co...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27507
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Argument types for `handles` and `labels` are too strict for method `Axes.legend`","articleBody":"### Bug summary\n\n`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.\n\n### Code for reproduction\n\n```python\nhandles, labels = ax.get_legend_handles_labels()\r\nax.legend(iter(handles), iter(labels))\n```\n\n\n### Actual outcome\n\nNo overload variant of \"legend\" of \"Axes\" matches argument types \"Iterator[Artist]\", \"Iterator[Any]\" [call-overload]\n\n### Expected outcome\n\nPasses without type error\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.8.2\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.10\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/Daverball","@type":"Person","name":"Daverball"},"datePublished":"2023-12-12T16:09:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/27507/matplotlib/issues/27507"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1574e824-fcea-26f1-600b-3cd63c62c8bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7DC:24C7F8:229601A:2F6E87A:6A542603 |
| html-safe-nonce | a48b6fdf1ac07747c1992ae18350c75877c0ceaa6cd3d00936651eb901e63495 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0RDOjI0QzdGODoyMjk2MDFBOjJGNkU4N0E6NkE1NDI2MDMiLCJ2aXNpdG9yX2lkIjoiNjcyNzQwMDY0NTUyNjMwMDE2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7833d9aa33ded61ae175deb5e271185263fbe861a421a9d3c42042bd957f6b11 |
| hovercard-subject-tag | issue:2038099506 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/27507/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3fa08d74a7fdc115431e6f2161ccf0084cf58d75e2ada03e9a7dbd5fd67f1a34/matplotlib/matplotlib/issues/27507 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3fa08d74a7fdc115431e6f2161ccf0084cf58d75e2ada03e9a7dbd5fd67f1a34/matplotlib/matplotlib/issues/27507 |
| og:image:alt | 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. Co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Daverball |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width