ruff/crates/red_knot_python_semantic/resources/mdtest/assignment
David Peter ebcad6e641
[red-knot] Use try_call_dunder for augmented assignment (#16717)
## Summary

Uses the `try_call_dunder` infrastructure for augmented assignment and
fixes the logic to work for types other than `Type::Instance(…)`. This
allows us to infer the correct type here:
```py
x = (1, 2)
x += (3, 4)
reveal_type(x)  # revealed: tuple[Literal[1], Literal[2], Literal[3], Literal[4]]
```
Or in this (extremely weird) scenario:
```py
class Meta(type):
    def __iadd__(cls, other: int) -> str:
        return ""

class C(metaclass=Meta): ...

cls = C
cls += 1

reveal_type(cls)  # revealed: str
```

Union and intersection handling could also be improved here, but I made
no attempt to do so in this PR.

## Test Plan

New MD tests
2025-03-14 20:36:09 +01:00
..
annotations.md [red-knot] Enforce specifying paths for mdtest code blocks in a separate preceding line (#15890) 2025-02-04 08:27:17 +01:00
augmented.md [red-knot] Use try_call_dunder for augmented assignment (#16717) 2025-03-14 20:36:09 +01:00
multi_target.md [red-knot] Port type inference tests to new test framework (#13719) 2024-10-15 11:23:46 -07:00
unbound.md Migrate some inference tests to mdtests (#14795) 2024-12-06 11:19:22 +01:00
walrus.md [red-knot] Port type inference tests to new test framework (#13719) 2024-10-15 11:23:46 -07:00