Title: [Bug]: revealed type for `Figure.subfigures` is not correct · Issue #30313 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: revealed type for `Figure.subfigures` is not correct · Issue #30313 · matplotlib/matplotlib
X Title: [Bug]: revealed type for `Figure.subfigures` is not correct · Issue #30313 · matplotlib/matplotlib
Description: Bug summary The overloads for subfigures aren't quite correct The issue is that matplotlib/lib/matplotlib/figure.py Line 1604 in 4af03f4 def subfigures(self, nrows=1, ncols=1, squeeze=True, has squeeze=True as the default, but the first ...
Open Graph Description: Bug summary The overloads for subfigures aren't quite correct The issue is that matplotlib/lib/matplotlib/figure.py Line 1604 in 4af03f4 def subfigures(self, nrows=1, ncols=1, squeeze=True, has squ...
X Description: Bug summary The overloads for subfigures aren't quite correct The issue is that matplotlib/lib/matplotlib/figure.py Line 1604 in 4af03f4 def subfigures(self, nrows=1, ncols=1, squeeze=True, has...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30313
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: revealed type for `Figure.subfigures` is not correct","articleBody":"### Bug summary\n\nThe overloads for `subfigures` aren't quite correct\n\nThe issue is that\n\nhttps://github.com/matplotlib/matplotlib/blob/4af03f44b6be8dce3651d7a93a593e110998dbe1/lib/matplotlib/figure.py#L1604\n\nhas `squeeze=True` as the default, but the first overload incorrectly notes `False` as the default\n\nhttps://github.com/matplotlib/matplotlib/blob/1295158096805f6675cbb42f982ff6c1402e9ba7/lib/matplotlib/figure.pyi#L193-L204\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nfrom typing import reveal_type\n\nfig = plt.figure(layout='constrained', figsize=(10, 4))\n\nreveal_type(fig.subfigures(1, 2, wspace=0.07))\nreveal_type(fig.subfigures(1, 1, wspace=0.07))\n\nreveal_type(fig.subfigures(1, 2, wspace=0.07, squeeze=True))\nreveal_type(fig.subfigures(1, 1, wspace=0.07, squeeze=True))\n```\n\n### Actual outcome\n\n(running the above with mypy)\n\n```\nt.py:6: note: Revealed type is \"numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]]\"\nt.py:7: note: Revealed type is \"numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]]\"\nt.py:9: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\nt.py:10: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\n```\n\nNote that the reveal types differ, even though `squeeze=True` is the default\n\n### Expected outcome\n\n```\nt.py:6: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\nt.py:7: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\nt.py:9: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\nt.py:10: note: Revealed type is \"Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]\"\n```\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.3\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.12\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/MarcoGorelli","@type":"Person","name":"MarcoGorelli"},"datePublished":"2025-07-15T13:00:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/30313/matplotlib/issues/30313"}
| 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:2f704ad6-a3e1-941a-a58e-e4e39d041879 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF84:163E89:9D0B5E:D48A3E:6A5201DB |
| html-safe-nonce | 2ff9c537a59b18e66c5a8f44bea74b9dce7277202bc118316e5c899ff0bb8f61 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjg0OjE2M0U4OTo5RDBCNUU6RDQ4QTNFOjZBNTIwMURCIiwidmlzaXRvcl9pZCI6IjM5NjM4NTk0MTI3MTI1NTQ5NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c262cb728ecb1f35bc7ef76026458d9a8757938eb34a1ab99477acb8c7ba4ce |
| hovercard-subject-tag | issue:3232166430 |
| 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/30313/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ce21ee2a5ab83d5ee1a037be0948b655975d238c2e0e9900a7b730802ac62ef8/matplotlib/matplotlib/issues/30313 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ce21ee2a5ab83d5ee1a037be0948b655975d238c2e0e9900a7b730802ac62ef8/matplotlib/matplotlib/issues/30313 |
| og:image:alt | Bug summary The overloads for subfigures aren't quite correct The issue is that matplotlib/lib/matplotlib/figure.py Line 1604 in 4af03f4 def subfigures(self, nrows=1, ncols=1, squeeze=True, has squ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MarcoGorelli |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width