Title: Better error message for "Invalid type" · Issue #4030 · python/mypy · GitHub
Open Graph Title: Better error message for "Invalid type" · Issue #4030 · python/mypy
X Title: Better error message for "Invalid type" · Issue #4030 · python/mypy
Description: There several situations where a quite terse error message is given: Invalid type "__main__.T" -- this could be an attempt to use a variable as a type, attempt to use function as a type, unsupported forward reference, maybe some other. I...
Open Graph Description: There several situations where a quite terse error message is given: Invalid type "__main__.T" -- this could be an attempt to use a variable as a type, attempt to use function as a type, unsupporte...
X Description: There several situations where a quite terse error message is given: Invalid type "__main__.T" -- this could be an attempt to use a variable as a type, attempt to use function as a type, ...
Opengraph URL: https://github.com/python/mypy/issues/4030
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Better error message for \"Invalid type\"","articleBody":"There several situations where a quite terse error message is given: ``Invalid type \"__main__.T\"`` -- this could be an attempt to use a variable as a type, attempt to use function as a type, unsupported forward reference, maybe some other. I propose to make this error message more specific, or add a note:\r\n```\r\nerror: Invalid type \"__main__.f\"\r\nnote: Functions can't be used as a type\r\n```\r\nand\r\n```\r\nerror: Invalid type \"__main__.Alias\"\r\nnote: Variables can't be used as a type\r\n```\r\nThe second can be also useful if someone accidentally created a variable instead of an alias. In this case we can even append a link to docs, if we detect that variable has type ``Type[...]``.\r\n\r\nAnother similar terse error message is ``Invalid base class``. We can say which base is invalid, this will be useful in case of multiple bases on the same line, and maybe also add a note in some cases explaining why it is invalid, like ``note: Union types can't be subclassed``, so that it is clear what went wrong.","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2017-09-29T08:51:44Z","url":"https://github.com/python/mypy/issues/4030"}
| 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:428b94f7-29d7-7544-0531-f30ccee68e31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA1E:4D728:2A3FC75:374F736:6B000C78 |
| html-safe-nonce | 78e489a253b4ec7c2b5e9280728d40f382c75d902c663e2c9cda89160c875751 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTFFOjRENzI4OjJBM0ZDNzU6Mzc0RjczNjo2QjAwMEM3OCIsInZpc2l0b3JfaWQiOiI0OTExMjAxMTA0MDkzNTQzNjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2a8c1a992035c2fab125fed1992888e5c601d97b15b33f21e2faa9e22fc5eec1 |
| hovercard-subject-tag | issue:261573555 |
| 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/4030/issue_layout |
| twitter:image | https://opengraph.githubassets.com/69af17a36814bf387196939b8ab4808c983ad6cf69f4e32462b782c54406231a/python/mypy/issues/4030 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/69af17a36814bf387196939b8ab4808c983ad6cf69f4e32462b782c54406231a/python/mypy/issues/4030 |
| og:image:alt | There several situations where a quite terse error message is given: Invalid type "__main__.T" -- this could be an attempt to use a variable as a type, attempt to use function as a type, unsupporte... |
| 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