Skip to content

Better match narrowing for irrefutable mapping patterns - #20906

Merged
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:narrow107
Mar 4, 2026
Merged

Better match narrowing for irrefutable mapping patterns#20906
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:narrow107

Conversation

@hauntsaninja

@hauntsaninjahauntsaninja commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes#18950
Fixes this comment #19081 (comment) (previously improved on by #20744 and #20782 )

@hauntsaninjahauntsaninja mentioned this pull request Feb 26, 2026
@github-actions

This comment has been minimized.

@hauntsaninja
hauntsaninja marked this pull request as draft February 26, 2026 19:19
@hauntsaninja

Copy link
Copy Markdown
CollaboratorAuthor

Hm, need to make this a little bit more principled

@github-actions

Copy link
Copy Markdown
Contributor

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

@hauntsaninja
hauntsaninja marked this pull request as ready for review March 4, 2026 08:06
@hauntsaninja

Copy link
Copy Markdown
CollaboratorAuthor

Actually I'm going to go ahead and just merge this, since I want it in 1.20. The Any special case is not the worst thing ever

@hauntsaninja
hauntsaninja merged commit e413220 into python:masterMar 4, 2026
24 checks passed
@hauntsaninja
hauntsaninja deleted the narrow107 branch March 4, 2026 08:08
Sign up for freeto 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.

Narrow mapping types when pattern-matching an empty mapping

1 participant

@hauntsaninja