mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
![]() ## 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. |
||
---|---|---|
.. | ||
booleans.md | ||
classes.md | ||
custom.md | ||
instances.md | ||
integers.md |