Title: [2.4 regression] `valid-type` error for `cast("None", _)` -- "Invalid type comment or annotation" · Issue #22090 · python/mypy · GitHub
Open Graph Title: [2.4 regression] `valid-type` error for `cast("None", _)` -- "Invalid type comment or annotation" · Issue #22090 · python/mypy
X Title: [2.4 regression] `valid-type` error for `cast("None", _)` -- "Invalid type comment or annotation" · Issue #22090 · python/mypy
Description: repro.py: from typing import Any, cast def f(x: Any) -> None: return cast("None", x) 2.3.1: $ uvx --with="mypy==2.3.1" mypy repro.py Success: no issues found in 1 source file 2.4.0: $ uvx --with="mypy==2.4.0" mypy repro.py repro.py:5: er...
Open Graph Description: repro.py: from typing import Any, cast def f(x: Any) -> None: return cast("None", x) 2.3.1: $ uvx --with="mypy==2.3.1" mypy repro.py Success: no issues found in 1 source file 2.4.0: $ uvx --with="m...
X Description: repro.py: from typing import Any, cast def f(x: Any) -> None: return cast("None", x) 2.3.1: $ uvx --with="mypy==2.3.1" mypy repro.py Success: no issues found in 1 source file...
Opengraph URL: https://github.com/python/mypy/issues/22090
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[2.4 regression] `valid-type` error for `cast(\"None\", _)` -- \"Invalid type comment or annotation\"","articleBody":"`repro.py`:\n\n```py\nfrom typing import Any, cast\n\n\ndef f(x: Any) -> None:\n return cast(\"None\", x)\n```\n\n2.3.1:\n\n```shell\n$ uvx --with=\"mypy==2.3.1\" mypy repro.py\nSuccess: no issues found in 1 source file\n```\n\n2.4.0:\n\n```shell\n$ uvx --with=\"mypy==2.4.0\" mypy repro.py\nrepro.py:5: error: Invalid type comment or annotation [valid-type]\nFound 1 error in 1 file (checked 1 source file)\n```\n\nAt the time of writing, mypy-play.net doesn't yet support 2.4.0, unfortunately.","author":{"url":"https://github.com/jorenham","@type":"Person","name":"jorenham"},"datePublished":"2026-10-02T22:55:38Z","url":"https://github.com/python/mypy/issues/22090"}
| 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:46fec440-0f27-55b4-e754-0933e7b2bb81 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C77A:3CBF1A:2006031:2BD7208:6B0026C1 |
| html-safe-nonce | 541054f33aae2eab7830002dfabff27df5d3510887ee91a6c0837ef85ce15f30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzdBOjNDQkYxQToyMDA2MDMxOjJCRDcyMDg6NkIwMDI2QzEiLCJ2aXNpdG9yX2lkIjoiMzAyNTM4OTAzOTcwNTQwMTAyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 39b59117da7f10d7eee40bdb8bd6c287acefcc50d95f242c0749c11b2fd32b0c |
| hovercard-subject-tag | issue:5684413795 |
| 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/22090/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f713243fc5a06493fa1cfbfa7c1b5e22a1667f645c79af170af273335908d60/python/mypy/issues/22090 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f713243fc5a06493fa1cfbfa7c1b5e22a1667f645c79af170af273335908d60/python/mypy/issues/22090 |
| og:image:alt | repro.py: from typing import Any, cast def f(x: Any) -> None: return cast("None", x) 2.3.1: $ uvx --with="mypy==2.3.1" mypy repro.py Success: no issues found in 1 source file 2.4.0: $ uvx --with="m... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jorenham |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width