Fix checking of match sequence pattern against bounded type variables#18091
Merged
JukkaL merged 1 commit intopython:masterfrom Nov 15, 2024
Merged
Conversation
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
hauntsaninja
approved these changes
Nov 3, 2024
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks! Would it make sense to move logic into construct_sequence_child?
Collaborator
Author
|
Hmm, it probably would, though I'm hesitant to touch Lines 750 to 751 in 1f200dd Changing less now might make that a bit easier. |
Collaborator
Ok, let's merge this as is. |
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this pull request
Feb 11, 2026
The changes around narrow_sequence_child: - implement my suggestion from here: python#18091 (review) - remove an is_subtype check I don't understand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18089
Adds handling for bounded type variables when checking match sequence patterns.
Previously, this crashed. Now, this correctly narrows the upper bound of the type variable: