Skip to content

[ty] Use type context from augmented assignment dunder calls#22540

Merged
ibraheemdev merged 2 commits intomainfrom
ibraheem/augmented-assignment-tcx
Jan 26, 2026
Merged

[ty] Use type context from augmented assignment dunder calls#22540
ibraheemdev merged 2 commits intomainfrom
ibraheem/augmented-assignment-tcx

Conversation

@ibraheemdev
Copy link
Member

Summary

Resolves astral-sh/ty#2043.

@ibraheemdev ibraheemdev added the ty Multi-file analysis & type inference label Jan 12, 2026

// Restore the multi-inference state.
builder.context.set_multi_inference(was_in_multi_inference);
builder.set_multi_inference_state(old_multi_inference_state);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Desperately want a better way to handle multi-inference...

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 12, 2026

Typing conformance results

No changes detected ✅

@ibraheemdev
Copy link
Member Author

Looking into the typing conformance failure.

@ibraheemdev ibraheemdev force-pushed the ibraheem/augmented-assignment-tcx branch from e37fc1c to 27ac08c Compare January 12, 2026 22:22
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 12, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing ibraheem/augmented-assignment-tcx (0d8d540) with main (8acd52d)

Summary

✅ 23 untouched benchmarks
⏩ 30 skipped benchmarks1

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 12, 2026

mypy_primer results

Changes were detected when running on open source projects
meson (https://github.com/mesonbuild/meson)
- mesonbuild/dependencies/configtool.py:136:13: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[str | AnsiDecorator]` and `list[Unknown | AnsiDecorator | str | None]`
+ mesonbuild/dependencies/configtool.py:136:13: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[str | AnsiDecorator]` and `list[AnsiDecorator | str | None]`
- run_project_tests.py:901:17: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[tuple[str, str, bool, bool]]` and `list[Unknown | tuple[Unknown, None, bool, bool]]`
+ run_project_tests.py:901:17: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[tuple[str, str, bool, bool]]` and `list[tuple[Unknown, None, bool, bool]]`

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 3 union elements` is not assignable to `dict[str, Any]`
- src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Argument type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `dict[str, Any] | int | Unknown | ... omitted 4 union elements` on object of type `dict[str, Any]`
+ src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown | dict[str, Any]` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | dict[str, Any] | int | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | dict[str, Any]]`
- src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown]`
- src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown]`
+ src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `str | dict[str, Any]` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `dict[str, Any] | int | str | ... omitted 3 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:234:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `int | Unknown | float | ... omitted 4 union elements`
- Found 5365 diagnostics
+ Found 5359 diagnostics

static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/bus.py:675:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemILocReduces[Bus[Any], object_]`, found `InterGetItemILocReduces[Self@iloc | Bus[Any], object_ | Self@iloc]`
+ static_frame/core/bus.py:671:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemLocReduces[Bus[Any], object_]`, found `InterGetItemLocReduces[Bus[Any] | Bottom[Series[Any, Any]] | TypeBlocks | ... omitted 6 union elements, object_]`
+ static_frame/core/bus.py:675:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemILocReduces[Bus[Any], object_]`, found `InterGetItemILocReduces[Bus[Any] | Bottom[Index[Any]] | Bottom[Series[Any, Any]] | ... omitted 7 union elements, object_ | Self@iloc]`
+ static_frame/core/series.py:772:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemILocReduces[Series[Any, Any], TVDtype@Series]`, found `InterGetItemILocReduces[Series[Any, Any] | IndexHierarchy | TypeBlocks | ... omitted 7 union elements, TVDtype@Series]`
+ static_frame/core/series.py:4072:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemILocReduces[SeriesHE[Any, Any], TVDtype@SeriesHE]`, found `InterGetItemILocReduces[Bottom[Series[Any, Any]] | Bottom[Index[Any]] | TypeBlocks | ... omitted 8 union elements, TVDtype@SeriesHE]`
+ static_frame/core/yarn.py:418:16: error[invalid-return-type] Return type does not match returned value: expected `InterGetItemILocReduces[Yarn[Any], object_]`, found `InterGetItemILocReduces[Yarn[Any] | IndexHierarchy | TypeBlocks | ... omitted 7 union elements, object_]`
- Found 1819 diagnostics
+ Found 1823 diagnostics

rotki (https://github.com/rotki/rotki)
- rotkehlchen/tests/unit/accounting/test_settings.py:180:5: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[SwapEvent]` and `list[Unknown | MarginPosition]`
+ rotkehlchen/tests/unit/accounting/test_settings.py:180:5: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[SwapEvent]` and `list[MarginPosition]`

core (https://github.com/home-assistant/core)
- homeassistant/components/nexia/entity.py:110:9: error[unsupported-operator] Operator `|=` is not supported between objects of type `DeviceInfo` and `dict[Unknown | str, Unknown | set[Unknown | tuple[str, Unknown]] | tuple[str, Unknown]]`
- Found 14495 diagnostics
+ Found 14494 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 12, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-return-type 0 3 3
invalid-argument-type 2 1 1
unsupported-operator 0 1 3
unused-ignore-comment 0 2 0
Total 2 7 7

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood removed their request for review January 13, 2026 15:48
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@ibraheemdev ibraheemdev enabled auto-merge (squash) January 26, 2026 22:50
@ibraheemdev ibraheemdev merged commit a89bcfa into main Jan 26, 2026
48 checks passed
@ibraheemdev ibraheemdev deleted the ibraheem/augmented-assignment-tcx branch January 26, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<TypedDict> |= {} fails with unsupported-operator

2 participants