ruff/crates/red_knot_python_semantic/resources/mdtest/loops
David Peter 86b01d2d3c
[red-knot] Correct modeling of dunder calls (#16368)
## Summary

Model dunder-calls correctly (and in one single place), by implementing
this behavior (using `__getitem__` as an example).

```py
def getitem_desugared(obj: object, key: object) -> object:
    getitem_callable = find_in_mro(type(obj), "__getitem__")
    if hasattr(getitem_callable, "__get__"):
        getitem_callable = getitem_callable.__get__(obj, type(obj))

    return getitem_callable(key)
```

See the new `calls/dunder.md` test suite for more information. The new
behavior also needs much fewer lines of code (the diff is positive due
to new tests).

## Test Plan

New tests; fix TODOs in existing tests.
2025-02-25 20:38:15 +01:00
..
async_for.md [red-knot] Meta data for Type::Todo (#14500) 2024-11-21 09:59:47 +01:00
for.md [red-knot] Correct modeling of dunder calls (#16368) 2025-02-25 20:38:15 +01:00
iterators.md [red-knot] Format mdtest Python snippets more concisely (#13905) 2024-10-24 11:09:31 +00:00
while_loop.md [red-knot] Diagnostics for incorrect bool usages (#16238) 2025-02-21 19:26:05 +01:00