Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #20606

This fixes couple edge cases where walrus interferes with type inference fallback logic. This is not a complete fix, but I think it is OK for now as these are probably rare situations. Most changes in binder.py are a pure performance optimization to compensate the fact that frame_context() will be more hot now. I also leave a TODO explaining a more proper fix for the assignment case (and other possible cases), return case should be already good (it is simpler since we don't need to apply any of the narrowing).

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi ilevkivskyi merged commit 32897bf into python:master Jan 20, 2026
23 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-walrus-inference branch January 20, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.18 regression] False negative with variable increment in a walrus inside a tuple

2 participants