You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior to this change, we could recognize exhaustive match statements when a fixed tuple's finite combinations were written as an explicit union, but not when those alternatives were hidden inside the tuple element types:
deff(b_1: bool, b_2: bool) ->int:
match (b_1, b_2):
case (True, True):
return0case (False, _):
return1case (_, False):
return2
We now share the existing bounded type-expansion logic used during overload resolution and use the expanded union when computing match reachability. For tuple[bool, bool], this lets each preceding case subtract the combinations it covers until no alternatives remain.
The expanded type is used only for reachability, so subject and capture inference remain unchanged. Tuple products remain capped at 64 alternatives; larger products keep the existing conservative behavior. This also resolves the existing tuple[int | str] sequence-pattern exhaustiveness TODO.
Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 94.37%. The percentage of expected errors that received a diagnostic held steady at 89.00%. The number of fully passing files held steady at 94/134.
mitmproxy (https://github.com/mitmproxy/mitmproxy)
- test/mitmproxy/addons/test_dns_resolver.py:155:17 error[type-assertion-failure] Type `@Todo` is not equivalent to `Never`
Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.
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
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.
Summary
Prior to this change, we could recognize exhaustive match statements when a fixed tuple's finite combinations were written as an explicit union, but not when those alternatives were hidden inside the tuple element types:
We now share the existing bounded type-expansion logic used during overload resolution and use the expanded union when computing match reachability. For
tuple[bool, bool], this lets each preceding case subtract the combinations it covers until no alternatives remain.The expanded type is used only for reachability, so subject and capture inference remain unchanged. Tuple products remain capped at 64 alternatives; larger products keep the existing conservative behavior. This also resolves the existing
tuple[int | str]sequence-pattern exhaustiveness TODO.Closes astral-sh/ty#3807.