Title: [MNT] [TYPING]: Use of Literal · Issue #30257 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT] [TYPING]: Use of Literal · Issue #30257 · matplotlib/matplotlib
X Title: [MNT] [TYPING]: Use of Literal · Issue #30257 · matplotlib/matplotlib
Description: Summary While checking pyplot and corresponding matplotlib methods, I noticed that there are several functions where we could use typing.Literal to explicitly indicate the possible values and have them suggested by IDEs. We also can crea...
Open Graph Description: Summary While checking pyplot and corresponding matplotlib methods, I noticed that there are several functions where we could use typing.Literal to explicitly indicate the possible values and have ...
X Description: Summary While checking pyplot and corresponding matplotlib methods, I noticed that there are several functions where we could use typing.Literal to explicitly indicate the possible values and have ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30257
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT] [TYPING]: Use of Literal","articleBody":"### Summary\n\nWhile checking `pyplot` and corresponding `matplotlib` methods, I noticed that there are several functions where we could use `typing.Literal` to explicitly indicate the possible values and have them suggested by IDEs.\nWe also can create the corresponding TypeAlias on `matplotlib.typing` when necessary.\n\n### Proposed fix\n\n| Function | Parameter | Literal replacing str | PR |\n|--------|--------|--------|--------|\n| mpl.set_loglevel | level | `\"notset\", \"debug\", \"info\", \"warning\", \"error\", \"critical\"` | #30302 |\n| plt.connect | s | `\"button_press_event\", \"button_release_event\"`, ... | #30275 |\n| plt.Axes.scatter | marker | _See MarkerType behind_ | #30261 |\n| mpl.rc | group | `\"animation\", \"axes\", axes3d, \"axes3d\", \"boxplot\"`, ... | #30316 |\n| mpl.RcParams.__get_item__ / __set_item__ | key | -- | #30316 |\n\n| Type | Literal replacing str | PR |\n|--------|--------|--------|\n| MarkerType | \".\", \",\", \"o\" | #30261 |\n\nOn MarkerType we can also add litterals for the tuple version that is not indicated for now:\n```py\ntuple[int, Literal[1, 2, 3], int]\n```","author":{"url":"https://github.com/ZPyrolink","@type":"Person","name":"ZPyrolink"},"datePublished":"2025-07-03T20:39:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/30257/matplotlib/issues/30257"}
| 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:605f2c78-67d8-8718-d477-b9d5d04b7ed7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A326:94837:B1CEAE:F0C321:6A51EC9C |
| html-safe-nonce | bd18153ae863c745df301af647031d7f0abcf3b9e9c7bf7545a010b059ef11bf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzI2Ojk0ODM3OkIxQ0VBRTpGMEMzMjE6NkE1MUVDOUMiLCJ2aXNpdG9yX2lkIjoiNzgzNjcyMjg2MzM2OTQ4MTM3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 669f2f0e82352dc5f6709dccea8ec58244f6ffd8de6815efa160f5489f574706 |
| hovercard-subject-tag | issue:3200585245 |
| 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/30257/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7f2351ff3e7df2c044778d337acc53d3a108bbdcf1436f3f91afc735ebb4a91e/matplotlib/matplotlib/issues/30257 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f2351ff3e7df2c044778d337acc53d3a108bbdcf1436f3f91afc735ebb4a91e/matplotlib/matplotlib/issues/30257 |
| og:image:alt | Summary While checking pyplot and corresponding matplotlib methods, I noticed that there are several functions where we could use typing.Literal to explicitly indicate the possible values and have ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ZPyrolink |
| 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