Title: Type inference problem in generic function · Issue #603 · python/mypy · GitHub
Open Graph Title: Type inference problem in generic function · Issue #603 · python/mypy
X Title: Type inference problem in generic function · Issue #603 · python/mypy
Description: Mypy complains about the following code: from typing import TypeVar, List T = TypeVar('T') def f(a: T) -> None: l = [] # type: List[T] # Error, even though this should be fine The reason for the error seems to be that the type variable t...
Open Graph Description: Mypy complains about the following code: from typing import TypeVar, List T = TypeVar('T') def f(a: T) -> None: l = [] # type: List[T] # Error, even though this should be fine The reason for the er...
X Description: Mypy complains about the following code: from typing import TypeVar, List T = TypeVar('T') def f(a: T) -> None: l = [] # type: List[T] # Error, even though this should be fine The reason...
Opengraph URL: https://github.com/python/mypy/issues/603
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference problem in generic function","articleBody":"Mypy complains about the following code:\n\n```\nfrom typing import TypeVar, List\nT = TypeVar('T')\ndef f(a: T) -> None:\n l = [] # type: List[T] # Error, even though this should be fine\n```\n\nThe reason for the error seems to be that the type variable type `T` in `List[T]` is erased so that it won't conflict with the type variables used for inferring the type of the list expression. Both type variables should be able to coexist during type inference.\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2015-03-15T20:51:02Z","url":"https://github.com/python/mypy/issues/603"}
| 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:18b8ec8a-e5b3-c996-3795-7165ac7effd3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D76A:194E10:17D58AE:2019042:6AFFEE31 |
| html-safe-nonce | f4f11fb32c1e1c36d18655e8984552374e3ad4cea41548e5645c0b9057cab4e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzZBOjE5NEUxMDoxN0Q1OEFFOjIwMTkwNDI6NkFGRkVFMzEiLCJ2aXNpdG9yX2lkIjoiNjQwMDI5OTg1MzI4NDM3MjAxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fd5add94f3f662b4706f4b19f37f5f6cb47a863bb03f2c4058f8ce060adb8dd6 |
| hovercard-subject-tag | issue:61897800 |
| 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/603/issue_layout |
| twitter:image | https://opengraph.githubassets.com/85ae0b1814e7b37d5e8dd433ed85cc1cc1eed94d29de02967e6dd59d7be38ef5/python/mypy/issues/603 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/85ae0b1814e7b37d5e8dd433ed85cc1cc1eed94d29de02967e6dd59d7be38ef5/python/mypy/issues/603 |
| og:image:alt | Mypy complains about the following code: from typing import TypeVar, List T = TypeVar('T') def f(a: T) -> None: l = [] # type: List[T] # Error, even though this should be fine The reason for the er... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| 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