Skip to content

Fix in-place operator lookup on asymmetric properties - #22275

Closed
guitarmanchan911-byte wants to merge 1 commit into
python:masterfrom
guitarmanchan911-byte:fix-augmented-assignment-property
Closed

guitarmanchan911-byte wants to merge 1 commit into
python:masterfrom
guitarmanchan911-byte:fix-augmented-assignment-property

Conversation

@guitarmanchan911-byte

Copy link
Copy Markdown

Fixes #22273.

Augmented assignment on a property or descriptor now resolves the
in-place operator method on the getter type, then checks the result
against the setter type. Previously the setter type was used for both,
which caused false positives when it was a union without the in-place
method.

Verification: added a regression test; mypy/test/testcheck.py passes
(8332 passed, 34 skipped, 7 xfailed).

AI assistance: Codex (GPT-5) was used for investigation and
implementation.

Augmented assignment now looks up the in-place operator method on the
type returned by the getter rather than the type accepted by the setter.
This matters for properties and descriptors whose getter and setter
types differ.

Fixes python#22273.

Assisted-by: Codex:GPT-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Augmented assignment on asymmetric property uses setter type to resolve __iadd__

2 participants