Title: Can't have an alias that just targets a type variable · Issue #543 · python/typing · GitHub
Open Graph Title: Can't have an alias that just targets a type variable · Issue #543 · python/typing
X Title: Can't have an alias that just targets a type variable · Issue #543 · python/typing
Description: Consider version 1 of my package, which defines T = TypeVar('T', int, float) MyType = Union[T, List[T]] # in the user's code U = TypeVar('U', int, float) def myfunc(MyType[U], U): ... In version 2, I decide to drop support for passing Li...
Open Graph Description: Consider version 1 of my package, which defines T = TypeVar('T', int, float) MyType = Union[T, List[T]] # in the user's code U = TypeVar('U', int, float) def myfunc(MyType[U], U): ... In version 2,...
X Description: Consider version 1 of my package, which defines T = TypeVar('T', int, float) MyType = Union[T, List[T]] # in the user's code U = TypeVar('U', int, float) def myfunc(MyType[U], U...
Opengraph URL: https://github.com/python/typing/issues/543
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't have an alias that just targets a type variable","articleBody":"Consider version 1 of my package, which defines\r\n\r\n```python\r\nT = TypeVar('T', int, float)\r\nMyType = Union[T, List[T]]\r\n\r\n# in the user's code\r\nU = TypeVar('U', int, float)\r\ndef myfunc(MyType[U], U): ...\r\n```\r\nIn version 2, I decide to drop support for passing `List[T]`. However, this causes an error on the downstream type definitions\r\n```python\r\nT = TypeVar('T', int, float)\r\nMyType = Union[T] # or Generic[T], or T - all fail\r\n\r\n# downstream code doesn't change - I want the freedom to change `MyType` again in future\r\nU = TypeVar('U', int, float)\r\ndef myfunc(MyType[U], U): ... # fails due to missing __getitem__\r\n```\r\n\r\nIs there a way to write this? Does implementing `TypeVar.__getitem__` seem reasonable? Or should we introduce `Identity[T]`, which boxes a typevar into a generic?\r\n","author":{"url":"https://github.com/eric-wieser","@type":"Person","name":"eric-wieser"},"datePublished":"2018-03-13T19:49:02Z","url":"https://github.com/python/typing/issues/543"}
| 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:31037923-ea77-ed8c-fd43-3e7e00b57b91 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C02:3A13A0:27A1D4D:35D4916:6B0042E4 |
| html-safe-nonce | 4af81a12aaa818b1e0444e72ce1a653fcdaf314131604d18c79dfa062f632415 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzAyOjNBMTNBMDoyN0ExRDREOjM1RDQ5MTY6NkIwMDQyRTQiLCJ2aXNpdG9yX2lkIjoiMzg2MDI4MDQ2MDk5NTIxNjEwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3a172d44bf688ba50785233ea3b3d1d434990b78c37ab40ed9bd754f7e0d7546 |
| hovercard-subject-tag | issue:304910462 |
| 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/typing/543/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4099263a251d3500c0037a95dfe90449dabab6ff5cdb469881225f7e9e2a4e9e/python/typing/issues/543 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4099263a251d3500c0037a95dfe90449dabab6ff5cdb469881225f7e9e2a4e9e/python/typing/issues/543 |
| og:image:alt | Consider version 1 of my package, which defines T = TypeVar('T', int, float) MyType = Union[T, List[T]] # in the user's code U = TypeVar('U', int, float) def myfunc(MyType[U], U): ... In version 2,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eric-wieser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width