mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
![]() ## 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 |
||
---|---|---|
.. | ||
mdtest | ||
README.md |
Markdown files within the mdtest/
subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs
integration test.
See crates/red_knot_test/README.md
for documentation of this test format.