ruff/crates/ty_python_semantic/resources/mdtest/generics/legacy
Alex Waygood 0639da2552
[ty] ~T should never be assignable to T (#20606)
## Summary

Currently we do not emit an error on this code:

```py
from ty_extensions import Not

def f[T](x: T, y: Not[T]) -> T:
    x = y
    return x
```

But we should do! `~T` should never be assignable to `T`.

This fixes a small regression introduced in
14fe1228e7 (diff-8049ab5af787dba29daa389bbe2b691560c15461ef536f122b1beab112a4b48aR1443-R1446),
where a branch that previously returned `false` was replaced with a
branch that returns `C::always_satisfiable` -- the opposite of what it
used to be! The regression occurred because we didn't have any tests for
this -- so I added some tests in this PR that fail on `main`. I only
spotted the problem because I was going through the code of
`has_relation_to_impl` with a fine toothcomb for
https://github.com/astral-sh/ruff/pull/20602 😄
2025-10-02 07:52:47 +01:00
..
classes.md [ty] Use typing.Self for the first parameter of instance methods (#20517) 2025-09-29 21:08:08 +02:00
functions.md [ty] ~T should never be assignable to T (#20606) 2025-10-02 07:52:47 +01:00
variables.md [ty] fix deferred name loading in PEP695 generic classes/functions (#19888) 2025-08-13 15:51:59 -07:00
variance.md [ty] eliminate is_fully_static (#18799) 2025-06-24 18:02:05 -07:00