Skip to content

Fix negative narrowing for containers#21411

Merged
hauntsaninja merged 2 commits intopython:masterfrom
hauntsaninja:containelse
May 5, 2026
Merged

Fix negative narrowing for containers#21411
hauntsaninja merged 2 commits intopython:masterfrom
hauntsaninja:containelse

Conversation

@hauntsaninja
Copy link
Copy Markdown
Collaborator

@hauntsaninja hauntsaninja commented May 5, 2026

Fixes #21409

While we may be able to conclude if color != Color.RED is unreachable, we cannot do so for containment

Relevant tests for the special case are in testNarrowingOptionalEqualsNone

Co-authored-by Codex

Fixes python#21409

Relevant tests for the special case are in testNarrowingOptionalEqualsNone

Co-authored-by Codex
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

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

@hauntsaninja hauntsaninja merged commit b7a8bab into python:master May 5, 2026
24 checks passed
@hauntsaninja hauntsaninja deleted the containelse branch May 5, 2026 06:09
hauntsaninja added a commit that referenced this pull request May 5, 2026
Fixes #21409

While we may be able to conclude `if color != Color.RED` is unreachable,
we cannot do so for containment

Relevant tests for the special case are in
testNarrowingOptionalEqualsNone

Co-authored-by Codex
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] False positive for checking reachability on dict with single-variant enum keys

1 participant