mirror of https://github.com/astral-sh/ruff
## 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.
|
||
|---|---|---|
| .. | ||
| instances | ||
| byte_literals.md | ||
| identity.md | ||
| integers.md | ||
| intersections.md | ||
| non_bool_returns.md | ||
| strings.md | ||
| tuples.md | ||
| unions.md | ||
| unsupported.md | ||