Title: [Bug/TYP]: misc type errors · Issue #26858 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug/TYP]: misc type errors · Issue #26858 · matplotlib/matplotlib
X Title: [Bug/TYP]: misc type errors · Issue #26858 · matplotlib/matplotlib
Description: Bug summary Pandas uses mypy/pyright to check its internal code. We currently pin matplotlib <3.8 to avoid many type errors pandas-dev/pandas#55210 Many of these errors are definitely on pandas's side :) but a few might be bugs in matplo...
Open Graph Description: Bug summary Pandas uses mypy/pyright to check its internal code. We currently pin matplotlib <3.8 to avoid many type errors pandas-dev/pandas#55210 Many of these errors are definitely on pandas's s...
X Description: Bug summary Pandas uses mypy/pyright to check its internal code. We currently pin matplotlib <3.8 to avoid many type errors pandas-dev/pandas#55210 Many of these errors are definitely on pandas&...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26858
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug/TYP]: misc type errors","articleBody":"### Bug summary\r\n\r\nPandas uses mypy/pyright to check its internal code. We currently pin matplotlib \u003c3.8 to avoid many type errors https://github.com/pandas-dev/pandas/pull/55210 Many of these errors are definitely on pandas's side :) but a few might be bugs in matplotlib.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\n# Simplified examples from pandas that trigger type errors\r\n\r\ndef format_date_labels(ax: Axes, rot) -\u003e None:\r\n for label in ax.get_xticklabels():\r\n label.set_ha(\"right\") # error: \"Text\" has no attribute \"set_ha\" [attr-defined]\r\n\r\n\r\ndef test(cellText: np.ndarray):\r\n # error: Argument \"cellText\" to \"table\" has incompatible type \"ndarray[Any, Any]\"; expected \"Sequence[Sequence[str]] | None\" [arg-type]\r\n # maybe use a Protocol such as Iterable?\r\n matplotlib.table.table(ax, cellText=cellText **kwargs)\r\n\r\n\r\ndef decorate_axes(ax: Axes, freq, kwargs) -\u003e None:\r\n # The following might just be bad pandas code\r\n # error: \"Axes\" has no attribute \"freq\" [attr-defined]\r\n ax.freq = freq\r\n xaxis = ax.get_xaxis()\r\n xaxis.freq = freq\r\n if not hasattr(ax, \"legendlabels\"):\r\n ax.legendlabels = [kwargs.get(\"label\", None)]\r\n else:\r\n ax.legendlabels.append(kwargs.get(\"label\", None))\r\n\r\n# error: Argument 1 to \"FixedLocator\" has incompatible type \"ndarray[Any, Any]\"; expected \"Sequence[float]\" [arg-type]\r\nFixedLocator(ax.get_xticks()) \r\n\r\n# same also for set_ylabel, maybe use a protocol for str-coercible types instead of requiring str\r\ndef test(ax: Axes, label: Hashable): # Hashable might be too wide, but str seems to strict\r\n ax.set_xlabel(label)\r\n\r\ndef test(ax: Axes):\r\n axes = np.array([ax])\r\n # error: Argument 1 to \"set_ticks_props\" has incompatible type \"ndarray[Any, dtype[Any]]\"; expected \"Axes | Sequence[Axes]\" [arg-type]\r\n set_ticks_props(axes, **kwargs)\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nthe above type errors\r\n\r\n### Expected outcome\r\n\r\nFewer errors, but still some errors - some of the pandas code is definitely to be blamed!\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Matplotlib Version\r\n\r\n3.8\r\n\r\n### Matplotlib Backend\r\n\r\n_No response_\r\n\r\n### Python version\r\n\r\n_No response_\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nNone","author":{"url":"https://github.com/twoertwein","@type":"Person","name":"twoertwein"},"datePublished":"2023-09-21T14:46:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/26858/matplotlib/issues/26858"}
| 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:28547ef2-db7d-5c4e-1627-8c4a8a90581c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0B6:3DC17:3762A8:4D376A:6A537450 |
| html-safe-nonce | 7dc246a10bf3ca58c978eaeb1b55ab156a520dbc1e6bd78a0466ca0f5ca7166f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEI2OjNEQzE3OjM3NjJBODo0RDM3NkE6NkE1Mzc0NTAiLCJ2aXNpdG9yX2lkIjoiNjA5NjA1NDAwNzkzMTA0MDg0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8f11a156dbebd72fbd1e90de93f0376d9891cd8e80a210e293a45a383317da98 |
| hovercard-subject-tag | issue:1907160295 |
| 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/26858/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7de846184ab0fc4b6fb5fc25352b0c1b47d988db796796ba502c8dfd5c9b91ab/matplotlib/matplotlib/issues/26858 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7de846184ab0fc4b6fb5fc25352b0c1b47d988db796796ba502c8dfd5c9b91ab/matplotlib/matplotlib/issues/26858 |
| og:image:alt | Bug summary Pandas uses mypy/pyright to check its internal code. We currently pin matplotlib <3.8 to avoid many type errors pandas-dev/pandas#55210 Many of these errors are definitely on pandas's s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | twoertwein |
| 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