Title: Added hardcoded colormap attributes for type checker support by bhpcv252 · Pull Request #30446 · matplotlib/matplotlib · GitHub
Open Graph Title: Added hardcoded colormap attributes for type checker support by bhpcv252 · Pull Request #30446 · matplotlib/matplotlib
X Title: Added hardcoded colormap attributes for type checker support by bhpcv252 · Pull Request #30446 · matplotlib/matplotlib
Description: PR summary This PR adds hardcoded attributes for named colormaps (e.g. gray, viridis, etc.) to cm.pyi, resolving issues where static type checkers (like mypy) report missing attributes on plt.cm. Since the colormaps are injected into the module at runtime using globals().update(_colormaps), a type checker cannot infer their presence without explicit stubs. This change follows the suggestion in #30438 to hardcode the list and can be paired with a test that ensures consistency with runtime-generated colormaps. Also, is the unit test okay for this? I'm parsing cm.pyi with a regex to collect all hardcoded colormap names and asserting that there are no missing names in the stub. Is this approach acceptable, or should I consider an alternative, like hardcoding the expected values in the test as well? Closes #30438
Open Graph Description: PR summary This PR adds hardcoded attributes for named colormaps (e.g. gray, viridis, etc.) to cm.pyi, resolving issues where static type checkers (like mypy) report missing attributes on plt.cm. S...
X Description: PR summary This PR adds hardcoded attributes for named colormaps (e.g. gray, viridis, etc.) to cm.pyi, resolving issues where static type checkers (like mypy) report missing attributes on plt.cm. S...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/30446
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aefc5422-68e8-950f-952f-e090f2caacc8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9BD4:D0CCD:D2ED61:11D9ADE:6A5213E9 |
| html-safe-nonce | 2495be7fb9baca28ad565ec73c23705047075ad0828e21971a848c13716bf43b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkQ0OkQwQ0NEOkQyRUQ2MToxMUQ5QURFOjZBNTIxM0U5IiwidmlzaXRvcl9pZCI6Ijg0ODEwMjg2NTQyNDczMTg1MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dda818580cb7a8c75de1ced63a26fcfd5447e706c90c94636f60eaa59445acab |
| hovercard-subject-tag | pull_request:2756744925 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/30446/files |
| twitter:image | https://avatars.githubusercontent.com/u/19909389?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/19909389?s=400&v=4 |
| og:image:alt | PR summary This PR adds hardcoded attributes for named colormaps (e.g. gray, viridis, etc.) to cm.pyi, resolving issues where static type checkers (like mypy) report missing attributes on plt.cm. S... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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