Skip to content

Better match narrowing for type objects#20872

Merged
hauntsaninja merged 1 commit intopython:masterfrom
hauntsaninja:narrow101
Feb 26, 2026
Merged

Better match narrowing for type objects#20872
hauntsaninja merged 1 commit intopython:masterfrom
hauntsaninja:narrow101

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Feb 23, 2026

This is the more general fix I alluded to in
#20367 (comment)

The tests I added do not yet have perfect behaviour, e.g. the type object unions should be allowed and should not have the branch marked as unreachable. I will open a PR for that next (it is easy, but the diff is thrashier so better for a separate PR)

Fixes #18470 , fixes comment in #17133 (comment)

@github-actions

This comment has been minimized.

This is the more general fix I alluded to in
python#20367 (comment)
@github-actions
Copy link
Contributor

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

@hauntsaninja
Copy link
Collaborator Author

Will merge this soon!

@hauntsaninja hauntsaninja merged commit 55401f2 into python:master Feb 26, 2026
24 checks passed
@hauntsaninja hauntsaninja deleted the narrow101 branch February 26, 2026 18:40
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.

Cannot infer type of generic type parm in match case statement

2 participants