Description
This is related to #12998.
https://mypy-play.net/?mypy=latest&python=3.12&gist=42bbd2ec432dbfd003429c64b8dc7435
from typing import assert_never
async def fn() -> int | None:
return None
async def foo() -> None:
match await fn():
case int():
pass
case None:
pass
case never:
assert_never(never) # error: Argument 1 to "assert_never" has incompatible type "int | None"; expected "NoReturn" [arg-type]
async def bar() -> None:
a = fn()
match await a:
case int():
pass
case None:
pass
case never:
assert_never(never) # error: Argument 1 to "assert_never" has incompatible type "int | None"; expected "NoReturn" [arg-type]
async def baz() -> None:
match _a := await fn():
case int():
pass
case None:
pass
case never:
assert_never(never) # works!
I also sent #17199 with a test case that demonstrates the bug.