Skip to content

Use getter type for augmented assignment to asymmetric properties - #22274

Open
mm21 wants to merge 1 commit into
python:masterfrom
mm21:master
Open

mm21 wants to merge 1 commit into
python:masterfrom
mm21:master

Conversation

@mm21

@mm21 mm21 commented Oct 22, 2026

Copy link
Copy Markdown

For obj.attr += x, look up and check the in-place method on the type read from the attribute (the property getter or descriptor __get__ result), and check the result against the type written to it (the setter or __set__ value type). Previously the setter type was used for both, which caused false positives and false negatives when the two types differ.

Fixes #22273

For `obj.attr += x`, look up and check the in-place method on the type
read from the attribute (the property getter or descriptor __get__
result), and check the result against the type written to it (the
setter or __set__ value type). Previously the setter type was used for
both, which caused false positives and false negatives when the two
types differ.

Fixes python#22273
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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__

1 participant