ruff/crates/ty_python_semantic/resources/mdtest/annotations
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
..
annotated.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
any.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
callable.md [ty] Silence false positives for PEP-695 ParamSpec annotations (#18001) 2025-05-10 11:59:25 +02:00
deferred.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
int_float_complex.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
invalid.md [ty] Improve invalid-type-form diagnostic where a module-literal type is used in a type expression and the module has a member which would be valid in a type expression (#18244) 2025-05-21 15:38:56 -04:00
literal.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
literal_string.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
never.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
new_types.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
optional.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
self.md [ty] Induct into instances and subclasses when finding and applying generics (#18052) 2025-05-12 21:53:11 -04:00
starred.md [ty] Understand homogeneous tuple annotations (#17998) 2025-05-12 22:02:25 -04:00
stdlib_typing_aliases.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
string.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
union.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unsupported_special_forms.md [ty] Understand homogeneous tuple annotations (#17998) 2025-05-12 22:02:25 -04:00
unsupported_special_types.md Generalize special-casing for enums constructed with the functional syntax (#17885) 2025-05-06 11:02:55 +01:00
unsupported_type_qualifiers.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00