ruff/crates/ty_python_semantic/resources/mdtest/annotations
David Peter 4ef2c223c9
[ty] Respect MRO_NO_OBJECT_FALLBACK policy when looking up symbols on type instances (#18312)
## Summary

This should address a problem that came up while working on
https://github.com/astral-sh/ruff/pull/18280. When looking up an
attribute (typically a dunder method) with the `MRO_NO_OBJECT_FALLBACK`
policy, the attribute is first looked up on the meta type. If the meta
type happens to be `type`, we go through the following branch in
`find_name_in_mro_with_policy`:


97ff015c88/crates/ty_python_semantic/src/types.rs (L2565-L2573)

The problem is that we now look up the attribute on `object` *directly*
(instead of just having `object` in the MRO). In this case,
`MRO_NO_OBJECT_FALLBACK` has no effect in `class_member_from_mro`:


c3feb8ce27/crates/ty_python_semantic/src/types/class.rs (L1081-L1082)

So instead, we need to explicitly respect the `MRO_NO_OBJECT_FALLBACK`
policy here by returning `Symbol::Unbound`.

## Test Plan

Added new Markdown tests that explain the ecosystem changes that we
observe.
2025-05-26 12:03:29 +02: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] Respect MRO_NO_OBJECT_FALLBACK policy when looking up symbols on type instances (#18312) 2025-05-26 12:03:29 +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