Title: [1.18 regression] False negative with variable increment in a walrus inside a tuple · Issue #20606 · python/mypy · GitHub
Open Graph Title: [1.18 regression] False negative with variable increment in a walrus inside a tuple · Issue #20606 · python/mypy
X Title: [1.18 regression] False negative with variable increment in a walrus inside a tuple · Issue #20606 · python/mypy
Description: Bug Report mypy sometimes fails to report errors in assignment expressions inside a tuple. To Reproduce def condition() -> bool: return False def fn() -> tuple[int, int]: i: int | None = 0 if condition() else None return (i, (i := i + 1)...
Open Graph Description: Bug Report mypy sometimes fails to report errors in assignment expressions inside a tuple. To Reproduce def condition() -> bool: return False def fn() -> tuple[int, int]: i: int | None = 0 if condi...
X Description: Bug Report mypy sometimes fails to report errors in assignment expressions inside a tuple. To Reproduce def condition() -> bool: return False def fn() -> tuple[int, int]: i: int | None = 0 if...
Opengraph URL: https://github.com/python/mypy/issues/20606
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[1.18 regression] False negative with variable increment in a walrus inside a tuple","articleBody":"**Bug Report**\n\nmypy sometimes fails to report errors in assignment expressions inside a tuple.\n\n**To Reproduce**\n\n```python\ndef condition() -> bool: return False\n\ndef fn() -> tuple[int, int]:\n i: int | None = 0 if condition() else None\n return (i, (i := i + 1))\n\nprint(fn())\n```\n\n**Expected Behavior**\n\nSomething like\n```\nlib.py:5: error: Incompatible return value type (got \"tuple[int | None, int]\", expected \"tuple[int, int]\") [return-value]\nlib.py:5: error: Unsupported operand types for + (\"None\" and \"int\") [operator]\nlib.py:5: note: Left operand is of type \"int | None\"\n```\n\n**Actual Behavior**\n\n```\nSuccess: no issues found in 1 source file\n```\n\n**Your Environment**\n\n- Mypy version used: 1.19.1 and master\n- Mypy command-line flags: n/a\n- Mypy configuration options from `mypy.ini` (and other config files): n/a\n- Python version used: 3.14.2\n\nThe weird thing is that if I change assignment target to a different variable like `(i, (j := i + 1))` mypy reports the two errors above.\nPossibly related to https://github.com/mypyc/mypyc/issues/1179","author":{"url":"https://github.com/hamdanal","@type":"Person","name":"hamdanal"},"datePublished":"2026-01-17T13:48:15Z","url":"https://github.com/python/mypy/issues/20606"}
| 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:433f57e4-1a83-81f0-66ff-59f26791f270 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 841E:73851:982260:D2309B:6B002D37 |
| html-safe-nonce | b7f8cb83c2a5e6bd1c14b6ac5fc291a7384220d501dff4caf2fc926766f48456 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDFFOjczODUxOjk4MjI2MDpEMjMwOUI6NkIwMDJEMzciLCJ2aXNpdG9yX2lkIjoiNDM3NjY3ODg2MTYyMzAxMjY2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 64d79b48684d7fadc4d16598699ef918597ffa38473370db3c7658430202f69a |
| hovercard-subject-tag | issue:3825218044 |
| 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/20606/issue_layout |
| twitter:image | https://opengraph.githubassets.com/475cfa070837b7e38d58b8d2fa26f1ce08853b6e5da09aa90b216faf40f8b549/python/mypy/issues/20606 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/475cfa070837b7e38d58b8d2fa26f1ce08853b6e5da09aa90b216faf40f8b549/python/mypy/issues/20606 |
| og:image:alt | Bug Report mypy sometimes fails to report errors in assignment expressions inside a tuple. To Reproduce def condition() -> bool: return False def fn() -> tuple[int, int]: i: int | None = 0 if condi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hamdanal |
| 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