Title: Unable to specify a default value for a generic parameter · Issue #3737 · python/mypy · GitHub
Open Graph Title: Unable to specify a default value for a generic parameter · Issue #3737 · python/mypy
X Title: Unable to specify a default value for a generic parameter · Issue #3737 · python/mypy
Description: Simplified Example: from typing import TypeVar _T = TypeVar('_T') def foo(a: _T = 42) -> _T: # E: Incompatible types in assignment (expression has type "int", variable has type "_T") return a Real World example is something closer to: _T...
Open Graph Description: Simplified Example: from typing import TypeVar _T = TypeVar('_T') def foo(a: _T = 42) -> _T: # E: Incompatible types in assignment (expression has type "int", variable has type "_T") return a Real ...
X Description: Simplified Example: from typing import TypeVar _T = TypeVar('_T') def foo(a: _T = 42) -> _T: # E: Incompatible types in assignment (expression has type "int", variable has type...
Opengraph URL: https://github.com/python/mypy/issues/3737
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unable to specify a default value for a generic parameter","articleBody":"Simplified Example:\r\n\r\n```python\r\nfrom typing import TypeVar\r\n\r\n_T = TypeVar('_T')\r\ndef foo(a: _T = 42) -> _T: # E: Incompatible types in assignment (expression has type \"int\", variable has type \"_T\")\r\n return a\r\n```\r\n\r\nReal World example is something closer to:\r\n\r\n```python\r\n_T = TypeVar('_T')\r\ndef noop_parser(x: str) -> str:\r\n return x\r\n\r\ndef foo(value: str, parser: Callable[[str], _T] = noop_parser) -> _T:\r\n return parser(value)\r\n```","author":{"url":"https://github.com/rowillia","@type":"Person","name":"rowillia"},"datePublished":"2017-07-19T01:33:47Z","url":"https://github.com/python/mypy/issues/3737"}
| 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:53f8b6a3-c2ef-c1c3-63ba-679c87a0e7c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8500:1833B7:6A6C13:8F6058:6AFF8CC3 |
| html-safe-nonce | bfb76d20850f61c160f53fc47ea1f281a85e8eb58ca05b554505127d6936e0a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTAwOjE4MzNCNzo2QTZDMTM6OEY2MDU4OjZBRkY4Q0MzIiwidmlzaXRvcl9pZCI6IjE0ODYyMjQ1NTM1NTMxMzY4MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0d8445e18bf67171df988d80cab4449eded2e5f54ff78c0d9a1bdf5739f0ac61 |
| hovercard-subject-tag | issue:243897727 |
| 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/3737/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6028d2b018674651a8dcc42405c590e2bb6d739ea188cb94ef18149d1aef4398/python/mypy/issues/3737 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6028d2b018674651a8dcc42405c590e2bb6d739ea188cb94ef18149d1aef4398/python/mypy/issues/3737 |
| og:image:alt | Simplified Example: from typing import TypeVar _T = TypeVar('_T') def foo(a: _T = 42) -> _T: # E: Incompatible types in assignment (expression has type "int", variable has type "_T") return a Real ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rowillia |
| hostname | github.com |
| expected-hostname | github.com |
| None | 587ad99a3e443b2e1cb0d3df059ec49ab54389861f13310766dfdeb615fed90d |
| 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 | 5bb0fb68d64881d1344f5863d809515d496801e5 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width