Title: Unbound parameters of type aliases silently default to Any · Issue #3386 · python/mypy · GitHub
Open Graph Title: Unbound parameters of type aliases silently default to Any · Issue #3386 · python/mypy
X Title: Unbound parameters of type aliases silently default to Any · Issue #3386 · python/mypy
Description: This may just be my misunderstanding, but it seems potentially undesirable, so I am reporting it as a bug. As of mypy 0.511, this typechecks just fine: from typing import TypeVar, Tuple V = TypeVar('V', bound=int) E = Tuple[V, V] def out...
Open Graph Description: This may just be my misunderstanding, but it seems potentially undesirable, so I am reporting it as a bug. As of mypy 0.511, this typechecks just fine: from typing import TypeVar, Tuple V = TypeVar...
X Description: This may just be my misunderstanding, but it seems potentially undesirable, so I am reporting it as a bug. As of mypy 0.511, this typechecks just fine: from typing import TypeVar, Tuple V = TypeVar...
Opengraph URL: https://github.com/python/mypy/issues/3386
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unbound parameters of type aliases silently default to Any","articleBody":"This may just be my misunderstanding, but it seems potentially undesirable, so I am reporting it as a bug. As of mypy 0.511, this typechecks just fine:\r\n\r\n```\r\nfrom typing import TypeVar, Tuple\r\n\r\nV = TypeVar('V', bound=int)\r\nE = Tuple[V, V]\r\n\r\ndef outgoing(edge: E) -> V: # Note unparameterized E\r\n reveal_type(edge) # Revealed type is 'Tuple[Any, Any]'\r\n return edge[1]\r\n\r\nprint(outgoing((1, 'a')))\r\n```\r\n\r\nIt looks like declaring a variable of type `E` ought to be the same as declaring it of type `Tuple[V, V]`, but in fact it becomes `Tuple[Any, Any]`. The issue is that the alias itself requires a type parameter (`E[V]`). This is a mistake that is both easy to make and silently removes type safety. Unfortunately, the PEP and docs are not very clear about aliases needing parameters. \r\n\r\nI'm not sure if there is a use case for missing alias parameters defaulting to `Any`, but it seems like type safety would be greatly improved it produced a typechecking error instead. It would really be convenient if mypy could try to bind missing type alias parameters to bound parameters of the same name, which would improve both usability and type safety. Thanks!","author":{"url":"https://github.com/jkleint","@type":"Person","name":"jkleint"},"datePublished":"2017-05-20T02:05:50Z","url":"https://github.com/python/mypy/issues/3386"}
| 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:30de6326-ee85-9f06-71d9-8e39c900b54e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBCA:7F150:1B521DD:2430B05:6B002C91 |
| html-safe-nonce | 7285e3d7e6d5732faa3f6b8bf18fb69dd2dc50615680cd1c789a0143d574d672 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkNBOjdGMTUwOjFCNTIxREQ6MjQzMEIwNTo2QjAwMkM5MSIsInZpc2l0b3JfaWQiOiI3ODQyNzIwMjU2OTI4Nzg3NjAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 86144d5977c60ca984d3f8d1b8f09942db91e4c26a96f29d7e3ec2fb5a69f620 |
| hovercard-subject-tag | issue:230123439 |
| 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/3386/issue_layout |
| twitter:image | https://opengraph.githubassets.com/91070449e3677a216c3ce0ac257a8a15c4afc4025a633008284d6581d2e42367/python/mypy/issues/3386 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/91070449e3677a216c3ce0ac257a8a15c4afc4025a633008284d6581d2e42367/python/mypy/issues/3386 |
| og:image:alt | This may just be my misunderstanding, but it seems potentially undesirable, so I am reporting it as a bug. As of mypy 0.511, this typechecks just fine: from typing import TypeVar, Tuple V = TypeVar... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jkleint |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width