Title: [mypy 2.4 regression] Incorrect type narrowing for reversed list of tuples · Issue #22174 · python/mypy · GitHub
Open Graph Title: [mypy 2.4 regression] Incorrect type narrowing for reversed list of tuples · Issue #22174 · python/mypy
X Title: [mypy 2.4 regression] Incorrect type narrowing for reversed list of tuples · Issue #22174 · python/mypy
Description: Bug Report As of mypy 2.4.0, code that iterates over a reversed list of tuples where one of the tuple elements is Any will infer that the type of every tuple element is Any. This is a change in behavior from 2.3.1, which breaks type chec...
Open Graph Description: Bug Report As of mypy 2.4.0, code that iterates over a reversed list of tuples where one of the tuple elements is Any will infer that the type of every tuple element is Any. This is a change in beh...
X Description: Bug Report As of mypy 2.4.0, code that iterates over a reversed list of tuples where one of the tuple elements is Any will infer that the type of every tuple element is Any. This is a change in beh...
Opengraph URL: https://github.com/python/mypy/issues/22174
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[mypy 2.4 regression] Incorrect type narrowing for reversed list of tuples","articleBody":"**Bug Report**\n\nAs of mypy 2.4.0, code that iterates over a reversed list of tuples where one of the tuple elements is Any will infer that the type of every tuple element is Any. This is a change in behavior from 2.3.1, which breaks type checking of existing code.\n\n**To Reproduce**\n\nUse [this Gist](https://mypy-play.net/?mypy=latest&python=3.12&flags=warn-return-any&gist=401cfc26981101164ab98385708ac43f)\n\n**Expected Behavior**\n\nSame as mypy 2.3.1, the type of the second element of the tuple should be `int`:\n```\nmain.py:5: note: Revealed type is \"int\"\nSuccess: no issues found in 1 source file\n```\n\n**Actual Behavior**\n\nOn mypy 2.4.0 the type of the second tuple element is inferred as `Any`:\n```\nmain.py:5: note: Revealed type is \"Any\"\nmain.py:6: error: Returning Any from function declared to return \"int | None\" [no-any-return]\nFound 1 error in 1 file (checked 1 source file)\n```\n\n**Your Environment**\n\n- Mypy version used: 2.4.0\n- Mypy command-line flags: --warn-return-any\n- Python version used: 3.12","author":{"url":"https://github.com/haudren-woven","@type":"Person","name":"haudren-woven"},"datePublished":"2026-10-07T01:07:51Z","url":"https://github.com/python/mypy/issues/22174"}
| 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:fbd20266-0f73-2a15-6f6f-4c09ff7dce71 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E81C:1EE22E:370EAF:4CBF85:6B005E39 |
| html-safe-nonce | 5e1d64706a4f72ced3626168377175aaa304c5201b8bf85eeb7c62c5718af920 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODFDOjFFRTIyRTozNzBFQUY6NENCRjg1OjZCMDA1RTM5IiwidmlzaXRvcl9pZCI6Ijg4Nzc2NzM0NjI0Nzk0NzgzMjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 44ac0926e813a3053a6e44ce1dc2dd6eeff2edc24d55c4e0fefb285f8eea0ddc |
| hovercard-subject-tag | issue:5796259717 |
| 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/22174/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da8978f71a7b4523817f8c5bee2df09f420ff658085faba358af03ab5501e5de/python/mypy/issues/22174 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da8978f71a7b4523817f8c5bee2df09f420ff658085faba358af03ab5501e5de/python/mypy/issues/22174 |
| og:image:alt | Bug Report As of mypy 2.4.0, code that iterates over a reversed list of tuples where one of the tuple elements is Any will infer that the type of every tuple element is Any. This is a change in beh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | haudren-woven |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| 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 | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width