-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#20882Labels
bugSomething isn't workingSomething isn't workingnarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowingruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Description
Summary
I just fixed a longstanding bug in pyright that ty appears to suffer from too. It's related to literal patterns in case statements. The runtime uses equality checks for literal pattern matching, but equality checks can succeed for non-overlapping types.
Consider the following:
def func(x: int):
match x:
case 1.0:
reveal_type(x) # ty incorrectly reveals Never here
print("This code is reachable")
func(1)Version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingnarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowingruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime