Title: Constrained TypeVars with Any default · Issue #20184 · python/mypy · GitHub
Open Graph Title: Constrained TypeVars with Any default · Issue #20184 · python/mypy
X Title: Constrained TypeVars with Any default · Issue #20184 · python/mypy
Description: Bug Report In python/typeshed#13683 I'm trying to change a type var to the following: _I = TypeVar("_I", int, bytes, float, bool, default=Any) # possibly memoryview types Unfortunately, mypy complains: error: TypeVar default must be one ...
Open Graph Description: Bug Report In python/typeshed#13683 I'm trying to change a type var to the following: _I = TypeVar("_I", int, bytes, float, bool, default=Any) # possibly memoryview types Unfortunately, mypy compla...
X Description: Bug Report In python/typeshed#13683 I'm trying to change a type var to the following: _I = TypeVar("_I", int, bytes, float, bool, default=Any) # possibly memoryview types Unfortunatel...
Opengraph URL: https://github.com/python/mypy/issues/20184
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constrained TypeVars with Any default","articleBody":"**Bug Report**\n\nIn python/typeshed#13683 I'm trying to change a type var to the following:\n\n```python\n_I = TypeVar(\"_I\", int, bytes, float, bool, default=Any) # possibly memoryview types\n```\n\nUnfortunately, mypy complains: `error: TypeVar default must be one of the constraint types [misc]`. While this is of course generally sound advice, a default of `Any` should always be permissible, as this allows `memoryview` to stand for any possible memoryview type. Without it, users are forced to write `memoryview[Any]` in every instance, which is unreasonable.\n\n**Your Environment**\n\n- Mypy version used: 1.18.2\n","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2025-11-05T09:59:01Z","url":"https://github.com/python/mypy/issues/20184"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:4a055935-e19b-1fe7-a3f6-d696e552c566 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D42:17F252:495CDD:64198C:6B007078 |
| html-safe-nonce | 78febab2ebb0ca082642b94970de94001e9b1071de371b0fd6fba63dbaecda6a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDQyOjE3RjI1Mjo0OTVDREQ6NjQxOThDOjZCMDA3MDc4IiwidmlzaXRvcl9pZCI6Ijg2MjM4MTU2Mjc5OTMyODA2MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bb042123e11558001ae1ff9992bd3c8b879409fa67268bbf448653a5acd313a1 |
| hovercard-subject-tag | issue:3590214216 |
| 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/python/mypy/20184/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aea243c5837788b96c8aa033baad12c4513e41027b4134e0c0a430d28fd774a9/python/mypy/issues/20184 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aea243c5837788b96c8aa033baad12c4513e41027b4134e0c0a430d28fd774a9/python/mypy/issues/20184 |
| og:image:alt | Bug Report In python/typeshed#13683 I'm trying to change a type var to the following: _I = TypeVar("_I", int, bytes, float, bool, default=Any) # possibly memoryview types Unfortunately, mypy compla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width