Skip to content

Narrow context fallback limitation to walrus only#21294

Merged
ilevkivskyi merged 1 commit intopython:masterfrom
ilevkivskyi:fix-ternary-context
Apr 22, 2026
Merged

Narrow context fallback limitation to walrus only#21294
ilevkivskyi merged 1 commit intopython:masterfrom
ilevkivskyi:fix-ternary-context

Conversation

@ilevkivskyi
Copy link
Copy Markdown
Member

Fixes #21273

This fixes regression caused by too cautious check in assignment context fallback. Ternary expression can change binder version, but only assignment expression can have an externally visible effect. So I add a dedicated counter to track this.

@github-actions
Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/execution/execute.py:1793: error: Unused "type: ignore" comment  [unused-ignore]

@ilevkivskyi
Copy link
Copy Markdown
Member Author

Primer looks good.

@ilevkivskyi ilevkivskyi merged commit 2b136f0 into python:master Apr 22, 2026
24 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-ternary-context branch April 22, 2026 23:38
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.20 regression] mypy no longer detects variable type narrowing via reassignment

2 participants