ruff/crates/ty_python_semantic/resources/mdtest/subscript
Alex Waygood d02c9ada5d
[ty] Do not carry the generic context of `Protocol` or `Generic` in the `ClassBase` enum (#17989)
## Summary

It doesn't seem to be necessary for our generics implementation to carry
the `GenericContext` in the `ClassBase` variants. Removing it simplifies
the code, fixes many TODOs about `Generic` or `Protocol` appearing
multiple times in MROs when each should only appear at most once, and
allows us to more accurately detect runtime errors that occur due to
`Generic` or `Protocol` appearing multiple times in a class's bases.

In order to remove the `GenericContext` from the `ClassBase` variant, it
turns out to be necessary to emulate
`typing._GenericAlias.__mro_entries__`, or we end up with a large number
of false-positive `inconsistent-mro` errors. This PR therefore also does
that.

Lastly, this PR fixes the inferred MROs of PEP-695 generic classes,
which implicitly inherit from `Generic` even if they have no explicit
bases.

## Test Plan

mdtests
2025-05-22 21:37:03 -04:00
..
bytes.md [ty] Integer indexing into `bytes` returns `int` (#18218) 2025-05-20 16:44:12 +02:00
class.md [ty] Rename `call-possibly-unbound-method` to `possibly-unbound-implicit-call` (#18017) 2025-05-22 15:25:51 +00:00
instance.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
lists.md [ty] Understand classes that inherit from subscripted `Protocol[]` as generic (#17832) 2025-05-09 17:39:15 +01:00
stepsize_zero.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
string.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
tuple.md [ty] Do not carry the generic context of `Protocol` or `Generic` in the `ClassBase` enum (#17989) 2025-05-22 21:37:03 -04:00