Title: Flaw with type aliases containing type variables · Issue #2690 · python/mypy · GitHub
Open Graph Title: Flaw with type aliases containing type variables · Issue #2690 · python/mypy
X Title: Flaw with type aliases containing type variables · Issue #2690 · python/mypy
Description: Reported by @mohabusama on gitter -- short version: from typing import * T = TypeVar('T', List[int], Dict) Processor = Callable[[T], None] def output2(inp: T, processor: Processor) -> T: processor(inp) def process_dict(inp: Dict) -> None...
Open Graph Description: Reported by @mohabusama on gitter -- short version: from typing import * T = TypeVar('T', List[int], Dict) Processor = Callable[[T], None] def output2(inp: T, processor: Processor) -> T: processor(...
X Description: Reported by @mohabusama on gitter -- short version: from typing import * T = TypeVar('T', List[int], Dict) Processor = Callable[[T], None] def output2(inp: T, processor: Processor) -> T:...
Opengraph URL: https://github.com/python/mypy/issues/2690
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flaw with type aliases containing type variables","articleBody":"Reported by @mohabusama on [gitter](reveal_type) -- short version:\r\n```python\r\nfrom typing import *\r\nT = TypeVar('T', List[int], Dict)\r\nProcessor = Callable[[T], None]\r\ndef output2(inp: T, processor: Processor) -> T:\r\n processor(inp)\r\ndef process_dict(inp: Dict) -> None:\r\n print(inp.keys())\r\noutput2([1, 2, 3], process_dict)\r\n```\r\nThere should be an error on the last line, but there isn't. Surrounding the line with `reveal_type()` shows that the inferred value for `T` is `List[int]`.\r\n\r\nIf we expand the type alias `Processor` inline in the signature of `output2()` we get the expected error:\r\n```\r\n__tmp__.py:8: error: Argument 2 to \"output2\" has incompatible type Callable[[Dict[Any, Any]], None]; expected Callable[[List[int]], None]\r\n```\r\nThis feels like a flaw in @ilevkivskyi's https://github.com/python/mypy/pull/2378 (which added support for type aliases containing type variables).","author":{"url":"https://github.com/gvanrossum","@type":"Person","name":"gvanrossum"},"datePublished":"2017-01-13T23:34:08Z","url":"https://github.com/python/mypy/issues/2690"}
| 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:a4c9ce5a-c144-95ca-281f-e3f0d7fc2fb6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DACA:1EE55B:1AB717B:2466D3C:6B000820 |
| html-safe-nonce | f33ed87accd03f1b9db033840ae0f7fec62c3d7febad81b202b560051812ed0f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUNBOjFFRTU1QjoxQUI3MTdCOjI0NjZEM0M6NkIwMDA4MjAiLCJ2aXNpdG9yX2lkIjoiMjA5MjY5NzMzOTAyNTE2NDMyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 10b4ba823be036d402c19d6f26ebaac283e156c601b6ab62b3ef243fb68340e6 |
| hovercard-subject-tag | issue:200758058 |
| 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/2690/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ad11062fcb9d41e61c3407fdce6bc6342b10444bb23ba64a5a45d3f2d6ec1a66/python/mypy/issues/2690 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ad11062fcb9d41e61c3407fdce6bc6342b10444bb23ba64a5a45d3f2d6ec1a66/python/mypy/issues/2690 |
| og:image:alt | Reported by @mohabusama on gitter -- short version: from typing import * T = TypeVar('T', List[int], Dict) Processor = Callable[[T], None] def output2(inp: T, processor: Processor) -> T: processor(... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gvanrossum |
| 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