Skip to content

[ty] Use key and value parameter types as type context for __setitem__ dunder calls#22148

Merged
ibraheemdev merged 3 commits intomainfrom
ibraheem/setitem-dunder-tcx
Jan 12, 2026
Merged

[ty] Use key and value parameter types as type context for __setitem__ dunder calls#22148
ibraheemdev merged 3 commits intomainfrom
ibraheem/setitem-dunder-tcx

Conversation

@ibraheemdev
Copy link
Member

Summary

Resolves astral-sh/ty#2136.

@ibraheemdev ibraheemdev added the ty Multi-file analysis & type inference label Dec 22, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

mypy_primer results

Changes were detected when running on open source projects
paroxython (https://github.com/laowantong/paroxython)
- paroxython/make_db.py:91:13: error[invalid-assignment] Invalid subscript assignment with key of type `ProgramPath` and value of type `dict[Unknown | str, Unknown | Source | dict[LabelName, list[tuple[int, int]]] | dict[TaxonName, list[tuple[int, int]]]]` on object of type `dict[ProgramPath, ProgramRecord]`
- Found 8 diagnostics
+ Found 7 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/environment/environment.py:1299:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | list[Unknown] | dict[Unknown, Unknown]]` on object of type `dict[str, dict[str, list[str]]]`
+ lib/spack/spack/environment/environment.py:1299:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[str, list[str] | dict[Unknown, Unknown]]` on object of type `dict[str, dict[str, list[str]]]`

pip (https://github.com/pypa/pip)
- src/pip/_internal/commands/search.py:101:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | list[Unknown | str]]` on object of type `OrderedDict[str, TransformedHit]`
- Found 603 diagnostics
+ Found 602 diagnostics

PyWinCtl (https://github.com/Kalmat/PyWinCtl)
- src/pywinctl/_pywinctl_linux.py:307:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | dict[Unknown, Unknown]]` on object of type `dict[str, _WINDICT]`
- Found 31 diagnostics
+ Found 30 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- tornado/gen.py:255:62: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]`, found `_T@next | _VT@next | _T@next`
+ tornado/gen.py:255:62: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]`, found `_T@next | _T@next | _VT@next`

urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/contrib/emscripten/fetch.py:400:34: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 306 diagnostics
+ Found 305 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/fields.py:943:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:943:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:983:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:983:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1026:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1026:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1066:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1066:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1109:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1109:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1148:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1148:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1188:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1188:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1567:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1567:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`

mypy (https://github.com/python/mypy)
- mypy/build.py:1176:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | (str & ~AlwaysFalsy) | int]` on object of type `dict[str, FgDepMeta]`
- Found 1740 diagnostics
+ Found 1739 diagnostics

freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/rpc/api_server/api_download_data.py:32:17: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown]` on object of type `dict[str, ProgressTask]`
- freqtrade/rpc/api_server/api_download_data.py:73:5: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | None | dict[Unknown, Unknown] | bool]` on object of type `dict[str, JobsContainer]`
- freqtrade/rpc/api_server/api_pairlists.py:92:5: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | None | bool | dict[Unknown, Unknown]]` on object of type `dict[str, JobsContainer]`
- Found 681 diagnostics
+ Found 678 diagnostics

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/cwlprov/ro.py:263:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | None]` on object of type `dict[str, Aggregate]`
- Found 257 diagnostics
+ Found 256 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/contrib/internal/ray/span_manager.py:214:17: error[invalid-assignment] Invalid subscript assignment with key of type `None | str` and value of type `dict[Unknown, Unknown]` on object of type `dict[str, dict[tuple[int, int], Span]]`
+ ddtrace/contrib/internal/ray/span_manager.py:214:17: error[invalid-assignment] Invalid subscript assignment with key of type `None | str` and value of type `dict[tuple[int, int], Span]` on object of type `dict[str, dict[tuple[int, int], Span]]`
- ddtrace/internal/remoteconfig/client.py:110:36: error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
- ddtrace/internal/remoteconfig/client.py:110:36: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
- ddtrace/internal/remoteconfig/client.py:110:36: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `object`
- ddtrace/internal/remoteconfig/client.py:110:36: error[invalid-argument-type] Argument is incorrect: Expected `Mapping[Unknown, Unknown]`, found `object`
- ddtrace/internal/remoteconfig/client.py:110:36: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `object`
- ddtrace/internal/remoteconfig/client.py:113:38: error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
- ddtrace/internal/remoteconfig/client.py:113:38: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `object`
- ddtrace/internal/remoteconfig/client.py:113:38: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `object`
- ddtrace/internal/remoteconfig/client.py:152:46: error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `object`
- ddtrace/internal/remoteconfig/client.py:152:46: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `object`
- ddtrace/internal/remoteconfig/client.py:152:46: error[invalid-argument-type] Argument is incorrect: Expected `Mapping[str, str]`, found `object`
- ddtrace/internal/remoteconfig/client.py:152:46: error[invalid-argument-type] Argument is incorrect: Expected `Mapping[str, Any]`, found `object`
- ddtrace/llmobs/_experiment.py:216:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str]` on object of type `dict[str, UpdatableDatasetRecord]`
- Found 8435 diagnostics
+ Found 8422 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any] | str | ... 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 `T@resolve_variables | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `T@resolve_variables | str | int | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_actions.py:193:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["push"]` and value of type `list[Unknown | dict[Unknown | str, Unknown | dict[Unknown | str, Unknown | str | None]]]` on object of type `list[dict[str, Any]]`
+ src/prefect/cli/deploy/_actions.py:193:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["push"]` and value of type `list[dict[str, Any]] & list[Unknown | dict[Unknown | str, Unknown | dict[Unknown | str, Unknown | str | None]]]` on object of type `list[dict[str, Any]]`
- src/prefect/cli/deploy/_actions.py:201:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["pull"]` and value of type `list[Unknown | dict[Unknown | str, Unknown | dict[Unknown | str, Unknown | str | None]]]` on object of type `list[dict[str, Any]]`
+ src/prefect/cli/deploy/_actions.py:201:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["pull"]` and value of type `list[dict[str, Any]] & list[Unknown | dict[Unknown | str, Unknown | dict[Unknown | str, Unknown | str | None]]]` on object of type `list[dict[str, Any]]`
- src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any] | str | ... 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 `T@resolve_variables` is not assignable to `dict[str, Any]`
+ src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `T@resolve_variables | str | int | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/deployments/runner.py:795:70: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((...) -> Any)`
+ src/prefect/deployments/runner.py:795:70: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((...) -> Any) & ((*args: object, **kwargs: object) -> object))`
- src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any]`
+ src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any] | str | ... omitted 4 union elements`
- src/prefect/flow_engine.py:812:32: error[invalid-await] `Unknown | R@FlowRunEngine | Coroutine[Any, Any, R@FlowRunEngine]` is not awaitable
- src/prefect/flow_engine.py:1401:24: error[invalid-await] `Unknown | R@AsyncFlowRunEngine | Coroutine[Any, Any, R@AsyncFlowRunEngine]` is not awaitable
- src/prefect/flow_engine.py:1482:43: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Unknown | R@run_generator_flow_sync`
- src/prefect/flow_engine.py:1490:21: warning[possibly-missing-attribute] Attribute `throw` may be missing on object of type `Unknown | R@run_generator_flow_sync`
- src/prefect/flow_engine.py:1524:44: warning[possibly-missing-attribute] Attribute `__anext__` may be missing on object of type `Unknown | R@run_generator_flow_async`
- src/prefect/flow_engine.py:1531:25: warning[possibly-missing-attribute] Attribute `throw` may be missing on object of type `Unknown | R@run_generator_flow_async`
- src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
+ src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
- src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
+ src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
+ src/prefect/flows.py:1750:53: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- src/prefect/locking/filesystem.py:138:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | datetime | None | Path]` on object of type `dict[str, _LockInfo]`
- src/prefect/locking/filesystem.py:187:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str | datetime | None | Path]` on object of type `dict[str, _LockInfo]`
- src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `T@resolve_block_document_references | dict[str, Any]` 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 `T@resolve_block_document_references | dict[str, Any] | str | ... omitted 4 union elements` 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[T@resolve_block_document_references | dict[str, Any] | Unknown]`
+ 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[T@resolve_block_document_references | dict[str, Any] | str | ... omitted 5 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, T@resolve_variables | Unknown]`
+ 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, T@resolve_variables | str | int | ... omitted 5 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[T@resolve_variables | 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[T@resolve_variables | str | int | ... omitted 5 union elements]`
- src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any]`
+ src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any] | str | ... omitted 4 union elements`
- src/prefect/workers/base.py:234:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `T@resolve_variables`
+ src/prefect/workers/base.py:234:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `T@resolve_variables | str | int | ... omitted 4 union elements`
- Found 5374 diagnostics
+ Found 5367 diagnostics

hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/threadingtools.py:261:21: error[invalid-assignment] Invalid subscript assignment with key of type `Node` and value of type `list[Element]` on object of type `dict[Node | Element, list[Node | Element]]`
- Found 665 diagnostics
+ Found 664 diagnostics

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/mzcompose/services/materialized.py:205:13: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["azurite", "minio"]` and value of type `dict[Unknown | str, Unknown | str]` on object of type `dict[str, ServiceDependency]`
- misc/python/materialize/mzcompose/services/materialized.py:251:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | str]` on object of type `dict[str, ServiceDependency]`
- Found 514 diagnostics
+ Found 512 diagnostics

static-frame (https://github.com/static-frame/static-frame)
+ 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]] | ndarray[Never, Never] | ... 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[Self@iloc | Bus[Any], object_ | Self@iloc]`
+ 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]] | TypeBlocks | ... omitted 6 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] | Bottom[Index[Any]] | ndarray[Never, Never] | ... omitted 6 union elements, TVDtype@Series]`
+ 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] | Bottom[Index[Any]] | TypeBlocks | ... omitted 6 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]] | ndarray[Never, Never] | TypeBlocks | ... omitted 7 union elements, TVDtype@SeriesHE]`
+ 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 7 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] | Bottom[Index[Any]] | TypeBlocks | ... omitted 6 union elements, object_]`
- Found 1825 diagnostics
+ Found 1827 diagnostics

rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/decoding/tools.py:96:44: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- rotkehlchen/chain/decoding/tools.py:99:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `Sequence[A@BaseDecoderTools]`, found `Unknown | tuple[BTCAddress, ...] | tuple[ChecksumAddress, ...] | tuple[SubstrateAddress, ...] | tuple[SolanaAddress, ...]`
- rotkehlchen/chain/decoding/tools.py:100:62: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+ rotkehlchen/chain/decoding/tools.py:97:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `BTCAddress | ChecksumAddress | SubstrateAddress | SolanaAddress`, found `A@BaseDecoderTools`
+ rotkehlchen/chain/decoding/tools.py:98:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `BTCAddress | ChecksumAddress | SubstrateAddress | SolanaAddress | None`, found `A@BaseDecoderTools | None`
- Found 2103 diagnostics
+ Found 2102 diagnostics

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_typing.pyi:1232:16: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 5169 diagnostics
+ Found 5170 diagnostics

zulip (https://github.com/zulip/zulip)
- zerver/lib/message.py:1016:13: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[str, Any]` on object of type `dict[int, RawUnreadStreamDict]`
- zerver/lib/message.py:1029:13: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[str, Any]` on object of type `dict[int, RawUnreadDirectMessageDict]`
- zerver/lib/message.py:1048:17: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[str, int | Unknown]` on object of type `dict[int, RawUnreadDirectMessageDict]`
- zerver/lib/message.py:1052:17: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[str, str]` on object of type `dict[int, RawUnreadDirectMessageGroupDict]`
- zerver/tornado/event_queue.py:1030:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | str` and value of type `dict[str, ClientDescriptor | list[Unknown] | bool]` on object of type `dict[str, ClientInfo]`
- zerver/tornado/event_queue.py:1041:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | str` and value of type `dict[str, ClientDescriptor | Any | bool]` on object of type `dict[str, ClientInfo]`
- zilencer/views.py:1734:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | int | None]` on object of type `dict[str, RemoteRealmDictValue]`
- Found 3679 diagnostics
+ Found 3672 diagnostics

core (https://github.com/home-assistant/core)
- homeassistant/components/media_player/__init__.py:1210:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | Lock]` on object of type `OrderedDict[str, _CacheImage]`
- homeassistant/components/recorder/statistics.py:555:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | int | float]` on object of type `dict[int, StatisticDataTimestamp]`
- homeassistant/components/recorder/statistics.py:579:17: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | int | float]` on object of type `dict[int, StatisticDataTimestamp]`
- homeassistant/components/sensor/recorder.py:830:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | StatisticMeanType | bool | None | str]` on object of type `dict[str, StatisticMetaData]`
- homeassistant/components/thread/diagnostics.py:93:9: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | bool]` on object of type `dict[str, Route]`
- homeassistant/components/thread/diagnostics.py:179:18: error[invalid-assignment] Invalid subscript assignment with key of type `str & ~AlwaysFalsy` and value of type `dict[Unknown | str, Unknown | str | (list[str] & ~AlwaysFalsy) | ... omitted 3 union elements]` on object of type `dict[str, Router]`
- homeassistant/components/traccar_server/coordinator.py:136:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | None | dict[str, Any]]` on object of type `dict[int, TraccarServerCoordinatorDataDevice]`
+ homeassistant/util/variance.py:47:12: error[invalid-return-type] Return type does not match returned value: expected `(**_P@ignore_variance) -> _R@ignore_variance`, found `_Wrapped[_P@ignore_variance, _R@ignore_variance | int | float | datetime, _P@ignore_variance, _R@ignore_variance | int | float | datetime]`
- Found 14504 diagnostics
+ Found 14498 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-assignment 0 28 9
invalid-argument-type 1 12 3
invalid-await 2 0 6
invalid-return-type 0 0 6
possibly-missing-attribute 3 0 1
unresolved-attribute 0 0 2
not-subscriptable 0 1 0
unused-ignore-comment 0 1 0
Total 6 42 27

Full report with detailed diff (timing results)

@ibraheemdev ibraheemdev marked this pull request as draft December 22, 2025 23:46
@ibraheemdev ibraheemdev force-pushed the ibraheem/setitem-dunder-tcx branch 5 times, most recently from cc72a35 to 97d313d Compare December 29, 2025 21:58
@ibraheemdev ibraheemdev marked this pull request as ready for review December 29, 2025 21:58
@ibraheemdev ibraheemdev force-pushed the ibraheem/setitem-dunder-tcx branch 2 times, most recently from db730f9 to bc245c4 Compare December 30, 2025 23:20
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.

Thank you!

Comment on lines +4051 to +4068
let ast_arguments = [
ArgOrKeyword::Arg(&target.slice),
ArgOrKeyword::Arg(rhs_value_node),
];

let mut call_arguments =
CallArguments::positional([Type::unknown(), Type::unknown()]);

let mut infer_argument_ty =
|builder: &mut Self, (argument_index, _, tcx): ArgExpr<'db, '_>| {
match argument_index {
0 => infer_slice_ty(builder, tcx),
1 => infer_rhs_value(builder, tcx),
_ => unreachable!(),
}
};

let Err(call_dunder_err) = self.infer_and_try_call_dunder(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the ergonomics of argument handling for self.infer_and_try_call_dunder could probably be better? But we can defer that to once we have >1 use of it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's just a little bit tricky because the underlying method infer_all_argument_types is meant to work with variadic AST arguments, while this case requires a custom inference method per argument. Open to suggestions.

@ibraheemdev ibraheemdev force-pushed the ibraheem/setitem-dunder-tcx branch from 25df5ff to ddcddab Compare January 12, 2026 20:51
@ibraheemdev ibraheemdev merged commit 8ac5f9d into main Jan 12, 2026
49 checks passed
@ibraheemdev ibraheemdev deleted the ibraheem/setitem-dunder-tcx branch January 12, 2026 21:05
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.

Use type context from __setitem__ signature to inform the type inferred on the right-hand side of subscript assignments

3 participants