Title: Type alias expansion sometimes interferes with type variable binding · Issue #3924 · python/mypy · GitHub
Open Graph Title: Type alias expansion sometimes interferes with type variable binding · Issue #3924 · python/mypy
X Title: Type alias expansion sometimes interferes with type variable binding · Issue #3924 · python/mypy
Description: Consider the following two examples, I think they should be equivalent, since logically expansion of type aliases should happen before any other steps. (At least this would be consistent and natural for those familiar with C macros): fro...
Open Graph Description: Consider the following two examples, I think they should be equivalent, since logically expansion of type aliases should happen before any other steps. (At least this would be consistent and natura...
X Description: Consider the following two examples, I think they should be equivalent, since logically expansion of type aliases should happen before any other steps. (At least this would be consistent and natura...
Opengraph URL: https://github.com/python/mypy/issues/3924
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type alias expansion sometimes interferes with type variable binding","articleBody":"Consider the following two examples, I think they should be equivalent, since logically expansion of type aliases should happen _before_ any other steps. (At least this would be consistent and natural for those familiar with C macros):\r\n```python\r\nfrom typing import TypeVar, Callable\r\nT = TypeVar('T')\r\n\r\ndef test1() -> Callable[[T], T]: ...\r\nreveal_type(test1) # Revealed type is 'def () -> def [T] (T`-1) -> T`-1'\r\nreveal_type(test1()) # Revealed type is 'def [T] (T`-1) -> T`-1'\r\n\r\nF = Callable[[T], T]\r\ndef test2() -> F[T]: ...\r\nreveal_type(test2) # Revealed type is 'def [T] () -> def (T`-1) -> T`-1'\r\nreveal_type(test2()) # Revealed type is 'def (\u003cnothing>) -> \u003cnothing>'\r\n```\r\nHere ``test1`` works as expected, while if I use an alias something strange happens with ``test2``. Namely notice a subtle difference between their types.\r\n```\r\ndef () -> def [T] (T`-1) -> T`-1\r\nand\r\ndef [T] () -> def (T`-1) -> T`-1\r\n```\r\nI have noticed few similar scenarios, they all seem to be related to ``Callable``.","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2017-09-06T12:32:13Z","url":"https://github.com/python/mypy/issues/3924"}
| 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:140efd6a-7c23-3343-f4c4-1e027c54d1c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B92:DCDA8:257EE82:30BD7D7:6AFFF45E |
| html-safe-nonce | 41c249ed95b2c9996af2ab3779fd99a89082fdcbfe04f0da470e424b77ab8b4b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjkyOkRDREE4OjI1N0VFODI6MzBCRDdENzo2QUZGRjQ1RSIsInZpc2l0b3JfaWQiOiI2Mzk5Njc5OTIxOTk5ODM2MjU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ca45c97f9f02298382067f8ebad647c295c130d00538cba17a7b278cfd382888 |
| hovercard-subject-tag | issue:255587050 |
| 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/3924/issue_layout |
| twitter:image | https://opengraph.githubassets.com/81eddd7f60d1e31cfe10f6380ae9ed861c5ad1565de7dee2dfd42d0c34638be9/python/mypy/issues/3924 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/81eddd7f60d1e31cfe10f6380ae9ed861c5ad1565de7dee2dfd42d0c34638be9/python/mypy/issues/3924 |
| og:image:alt | Consider the following two examples, I think they should be equivalent, since logically expansion of type aliases should happen before any other steps. (At least this would be consistent and natura... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilevkivskyi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width