Title: Regression: error messages for literal expressions in invalid places are worse · Issue #5989 · python/mypy · GitHub
Open Graph Title: Regression: error messages for literal expressions in invalid places are worse · Issue #5989 · python/mypy
X Title: Regression: error messages for literal expressions in invalid places are worse · Issue #5989 · python/mypy
Description: After #5947 (basic end-to-end support for literal types) lands, we'll start deferring some of the "invalid type" checks to the semantic analysis layer by wrapping them into a 'RawLiteralType'. This can, in some cases have an unintended s...
Open Graph Description: After #5947 (basic end-to-end support for literal types) lands, we'll start deferring some of the "invalid type" checks to the semantic analysis layer by wrapping them into a 'RawLiteralType'. This...
X Description: After #5947 (basic end-to-end support for literal types) lands, we'll start deferring some of the "invalid type" checks to the semantic analysis layer by wrapping them into a 'Raw...
Opengraph URL: https://github.com/python/mypy/issues/5989
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression: error messages for literal expressions in invalid places are worse","articleBody":"After https://github.com/python/mypy/pull/5947 (basic end-to-end support for literal types) lands, we'll start deferring some of the \"invalid type\" checks to the semantic analysis layer by wrapping them into a 'RawLiteralType'. This can, in some cases have an unintended side-effect of making some error messages worse. For example, writing `T = TypeVar('T', bound=1)` previously used to report error messages like \"TypeVar 'bound' must be a type\"; now they report error messages like `E: Invalid type: try using Literal[1] instead?`.\r\n\r\nWe ran into a similar case with 'NewType' -- in that case, we added some special-casing to restore the original error message. We could do the same thing here, and for other similar \"type-alias-like\" constructs such as NamedTuple or TypedDict.\r\n\r\nAlternatively, we could explore adding `TypeOfAny.invalid_type` as Ivan [suggests here](https://github.com/python/mypy/pull/5947#discussion_r238108162) -- this could also potentially help us resolve https://github.com/python/mypy/issues/4030 at the same time.\r\n\r\nNote to self: if it looks like literal types aren't going to make it into the next mypy release, we should at least fix this error and/or change any existing errors to make sure we never recommend using 'Literal[...]'. It would be confusing if error messages started talking about literal types before they're actually officially released.","author":{"url":"https://github.com/Michael0x2a","@type":"Person","name":"Michael0x2a"},"datePublished":"2018-12-02T23:59:53Z","url":"https://github.com/python/mypy/issues/5989"}
| 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:75536050-edd8-a8fb-4542-963908dc6e6f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87CA:2FF516:AE7CE8:E9F439:6B0048BC |
| html-safe-nonce | 24a1eacc95d78647dda74eb416ca0b5f6fa594e369753d1d02c16051fba64d30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0NBOjJGRjUxNjpBRTdDRTg6RTlGNDM5OjZCMDA0OEJDIiwidmlzaXRvcl9pZCI6Ijg4ODUwMjk0NzAxNDcyMDEyMTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3cb8fdd38d0bfdc3599c292400759969d46a59168e726105cc4c7adf60a716b7 |
| hovercard-subject-tag | issue:386616102 |
| 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/5989/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f378695b7fe47b8b51477963f2b846d16d576bd25eceae3273751f089e194fe/python/mypy/issues/5989 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f378695b7fe47b8b51477963f2b846d16d576bd25eceae3273751f089e194fe/python/mypy/issues/5989 |
| og:image:alt | After #5947 (basic end-to-end support for literal types) lands, we'll start deferring some of the "invalid type" checks to the semantic analysis layer by wrapping them into a 'RawLiteralType'. This... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Michael0x2a |
| 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