Files
Ibraheem Ahmed b140af2f48 [ty] Ignore type context when inferring assert_never arguments (#30389)
We internally declare the parameter type of the `assert_never` value to
be `Any`. However, this declared type should be ignored when inferring
the value expression, as it can sometimes prevent a nested generic call
from inferring `Never`, incorrectly silencing the assertion:

```py
from typing import Iterator, Never, assert_never

def _(items: Iterator[Never]):
    assert_never(next(items))  # main: error[type-assertion-failure], now: ok

def result[T = Never]() -> T:
    raise NotImplementedError

assert_never(result())   # main: error[type-assertion-failure], now: ok
```

Reported in
https://github.com/astral-sh/ty/issues/4988#issuecomment-6779572903.
2026-11-13 22:46:48 +00:00
..