Title: [Bug]: GridSpec do not type check as Iterable in zip · Issue #28151 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: GridSpec do not type check as Iterable in zip · Issue #28151 · matplotlib/matplotlib
X Title: [Bug]: GridSpec do not type check as Iterable in zip · Issue #28151 · matplotlib/matplotlib
Description: Bug summary GridSpec objects are iterable because they have a __getitem__ method. However, they are not a collections.abc.Iterable: [Iterable] does not detect classes that iterate with the __getitem__() method. This means that they do no...
Open Graph Description: Bug summary GridSpec objects are iterable because they have a __getitem__ method. However, they are not a collections.abc.Iterable: [Iterable] does not detect classes that iterate with the __getite...
X Description: Bug summary GridSpec objects are iterable because they have a __getitem__ method. However, they are not a collections.abc.Iterable: [Iterable] does not detect classes that iterate with the __getite...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28151
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: GridSpec do not type check as Iterable in zip","articleBody":"### Bug summary\n\n`GridSpec` objects are iterable because they have a `__getitem__` method. However, they are not a [`collections.abc.Iterable`](1):\r\n\r\n\u003e \\[`Iterable`\\] does not detect classes that iterate with the [`__getitem__()`](https://docs.python.org/3/reference/datamodel.html#object.__getitem__) method.\r\n\r\nThis means that they do not type check in `zip`, at least according to [typeshed](2)\r\n\r\n[1]: https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable\r\n[2]: https://github.com/python/typeshed/blob/78a86de5d966fe403c4184fb4a795e7fb559214b/stdlib/builtins.pyi#L1714\n\n### Code for reproduction\n\n```Python\nfrom matplotlib.gridspec import GridSpec\r\n\r\ngs = GridSpec(3, 3)\r\ncounter = range(9)\r\nfor cell in gs:\r\n print(cell)\r\n\r\nfor i, cell in zip(counter, gs):\r\n print(cell)\n```\n\n\n### Actual outcome\n\nCode runs, but type type checking says that GridSpec is not Iterable\n\n### Expected outcome\n\nType checks OK\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nLinux\n\n### Matplotlib Version\n\n3.8.4\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.10.12\n\n### Jupyter version\n\nN/A\n\n### Installation\n\npip","author":{"url":"https://github.com/Jacob-Stevens-Haas","@type":"Person","name":"Jacob-Stevens-Haas"},"datePublished":"2024-04-29T21:41:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/28151/matplotlib/issues/28151"}
| 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:ecb74c58-9439-830b-5468-f72fa78ec6c0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AAFC:2FDA55:12C7208:1AE8397:6A63445D |
| html-safe-nonce | 6c8b90f85cf0cf19103754aac99a8344240b39869cea9a01c0cf3a669205df89 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUZDOjJGREE1NToxMkM3MjA4OjFBRTgzOTc6NkE2MzQ0NUQiLCJ2aXNpdG9yX2lkIjoiNTIzNjMwNjY3MDMwMjQ3OTQ1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 223837a02042e9bd28832ee574b9ec7538a44cce65f1407b5b10544eabd62f83 |
| hovercard-subject-tag | issue:2270037735 |
| 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/28151/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3c707ea3a00d2b8cf28ecf563d1ec815e540b2eca83a3c50597ea3c9c1c6357/matplotlib/matplotlib/issues/28151 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3c707ea3a00d2b8cf28ecf563d1ec815e540b2eca83a3c50597ea3c9c1c6357/matplotlib/matplotlib/issues/28151 |
| og:image:alt | Bug summary GridSpec objects are iterable because they have a __getitem__ method. However, they are not a collections.abc.Iterable: [Iterable] does not detect classes that iterate with the __getite... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jacob-Stevens-Haas |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| 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 | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width