Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Use peer context for collection literals#25848

Merged
carljm merged 3 commits into
mainfrom
cjm/3574-3693-collection-literal-peer-context
Jun 11, 2026
Merged

[ty] Use peer context for collection literals#25848
carljm merged 3 commits into
mainfrom
cjm/3574-3693-collection-literal-peer-context

Conversation

@carljm

@carljm carljm commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Use the type of peer operands as context when inferring fresh list, set, and dict literals in boolean and conditional expressions. This prevents empty literals from introducing Unknown and preserves literal key types in fallback expressions such as values or [] and build_sort_spec(params) or {"name": -1}.

Peer context is applied speculatively and discarded if it introduces diagnostics, so it remains an inference hint rather than a new constraint. The implementation also preserves generic specialization by accumulating unguarded peer types before truthiness refinement, while retaining existing structured generic context when it is already useful.

Fixes astral-sh/ty#3574.
Fixes astral-sh/ty#3693.

Test Plan

Added/updated mdtests.

Ecosystem report is all good news. The new Apprise diagnostic is just a result of us not narrowing the place result["fullpath"] to truthy based on a check of result.get("fullpath"). This is orthogonal, just exposed by our better inference for result in the first place.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 10, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 94.36%. The percentage of expected errors that received a diagnostic held steady at 88.82%. The number of fully passing files held steady at 93/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
trio 86.82MB 86.82MB -
sphinx 205.01MB 205.01MB -0.00% (2.41kB) ⬇️
flake8 35.04MB 35.03MB -0.04% (15.71kB) ⬇️
prefect 555.11MB 555.00MB -0.02% (114.98kB) ⬇️

Significant changes

Click to expand detailed breakdown

sphinx

Name Old New Diff Outcome
UnionType<'db>::from_two_elements_ 292.19kB 291.64kB -0.19% (564.00B) ⬇️
infer_expression_types_impl 20.18MB 20.18MB -0.00% (480.00B) ⬇️
Type<'db>::apply_specialization_inner_ 1.51MB 1.51MB -0.03% (436.00B) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 1.40MB 1.40MB -0.03% (400.00B) ⬇️
infer_definition_types 20.03MB 20.04MB +0.00% (384.00B) ⬇️
CallableType 1.36MB 1.36MB -0.02% (304.00B) ⬇️
UnionType<'db>::from_two_elements_::interned_arguments 265.63kB 265.38kB -0.10% (264.00B) ⬇️
infer_scope_types_impl 12.44MB 12.44MB -0.00% (240.00B) ⬇️
UnionType 651.70kB 651.48kB -0.03% (224.00B) ⬇️
is_redundant_with_impl::interned_arguments 1.13MB 1.13MB +0.01% (176.00B) ⬇️
Specialization 1.26MB 1.26MB -0.01% (128.00B) ⬇️
is_redundant_with_impl 895.77kB 895.86kB +0.01% (96.00B) ⬇️
ExpressionWithContext 223.91kB 223.83kB -0.03% (80.00B) ⬇️

flake8

Name Old New Diff Outcome
when_constraint_set_assignable_to_owned_impl 152.20kB 149.79kB -1.58% (2.40kB) ⬇️
Type<'db>::apply_specialization_inner_ 181.45kB 180.09kB -0.75% (1.36kB) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 170.55kB 169.30kB -0.73% (1.25kB) ⬇️
infer_definition_types 1.52MB 1.52MB -0.08% (1.18kB) ⬇️
CallableType 204.12kB 203.05kB -0.53% (1.08kB) ⬇️
StaticClassLiteral<'db>::try_mro_ 290.96kB 289.94kB -0.35% (1.02kB) ⬇️
member_lookup_with_policy_inner 396.97kB 396.16kB -0.20% (828.00B) ⬇️
FunctionType 223.33kB 222.53kB -0.36% (816.00B) ⬇️
Specialization 171.12kB 170.36kB -0.45% (784.00B) ⬇️
Type<'db>::class_member_with_policy_ 316.21kB 315.64kB -0.18% (576.00B) ⬇️
cached_protocol_interface 52.16kB 51.64kB -0.99% (528.00B) ⬇️
infer_scope_types_impl 780.04kB 779.61kB -0.05% (432.00B) ⬇️
FunctionType<'db>::signature_ 273.19kB 272.82kB -0.14% (384.00B) ⬇️
is_possibly_constraint_set_assignable 24.28kB 23.93kB -1.45% (360.00B) ⬇️
member_lookup_with_policy_inner::interned_arguments 201.68kB 201.33kB -0.17% (360.00B) ⬇️
... 14 more

prefect

Name Old New Diff Outcome
is_redundant_with_impl 1.94MB 1.93MB -0.77% (15.21kB) ⬇️
infer_definition_types 72.97MB 72.96MB -0.01% (10.81kB) ⬇️
Type<'db>::apply_specialization_inner_ 3.17MB 3.16MB -0.32% (10.47kB) ⬇️
is_redundant_with_impl::interned_arguments 2.33MB 2.32MB -0.43% (10.31kB) ⬇️
Type<'db>::apply_specialization_inner_::interned_arguments 2.79MB 2.78MB -0.28% (8.12kB) ⬇️
infer_expression_types_impl 54.12MB 54.11MB -0.01% (7.59kB) ⬇️
UnionType 1.36MB 1.35MB -0.53% (7.45kB) ⬇️
member_lookup_with_policy_inner 13.25MB 13.24MB -0.05% (6.18kB) ⬇️
member_lookup_with_policy_inner::interned_arguments 6.66MB 6.66MB -0.06% (4.10kB) ⬇️
Specialization 2.50MB 2.49MB -0.16% (4.08kB) ⬇️
try_call_bin_op_return_type_impl 280.03kB 276.23kB -1.36% (3.80kB) ⬇️
is_possibly_constraint_set_assignable 507.71kB 504.28kB -0.68% (3.43kB) ⬇️
StaticClassLiteral<'db>::try_mro_ 4.31MB 4.31MB -0.07% (3.00kB) ⬇️
infer_scope_types_impl 47.09MB 47.09MB -0.01% (2.72kB) ⬇️
assignable_solutions_impl 294.58kB 296.71kB +0.72% (2.13kB) ⬇️
... 34 more

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 0 18 8
unresolved-attribute 2 1 16
no-matching-overload 0 9 0
invalid-assignment 0 2 6
unsupported-operator 1 6 1
invalid-return-type 0 1 3
not-subscriptable 0 1 0
redundant-cast 1 0 0
Total 4 38 34

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Raw diff (76 changes)
apprise (https://github.com/caronc/apprise)
- apprise/utils/parse.py:734:12 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/utils/parse.py:755:17 error[no-matching-overload] No overload of bound method `Pattern.search` matches arguments
- apprise/utils/parse.py:765:44 error[no-matching-overload] No overload of function `split` matches arguments
- apprise/utils/parse.py:771:52 error[no-matching-overload] No overload of function `split` matches arguments
- apprise/utils/parse.py:776:14 error[no-matching-overload] No overload of function `search` matches arguments
- apprise/utils/parse.py:790:13 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["port"]` and value of type `int` on object of type `dict[str, None | str | dict[Unknown, Unknown]]`
- apprise/utils/parse.py:832:9 error[unsupported-operator] Operator `+=` is not supported between objects of type `None` and `None | str | dict[Unknown, Unknown] | Unknown`
- apprise/utils/parse.py:832:9 error[unsupported-operator] Operator `+=` is not supported between objects of type `dict[Unknown, Unknown]` and `None | str | dict[Unknown, Unknown] | Unknown`
- apprise/utils/parse.py:832:9 error[unsupported-operator] Operator `+=` is not supported between objects of type `str` and `None | str | dict[Unknown, Unknown] | Unknown`
- apprise/utils/parse.py:839:5 error[unsupported-operator] Operator `+=` is not supported between objects of type `None` and `None | str | dict[Unknown, Unknown] | Unknown`
- apprise/utils/parse.py:839:5 error[unsupported-operator] Operator `+=` is not supported between objects of type `dict[Unknown, Unknown]` and `None | str | dict[Unknown, Unknown] | Unknown`
- apprise/utils/parse.py:839:5 error[unsupported-operator] Operator `+=` is not supported between objects of type `str` and `None | str | dict[Unknown, Unknown] | Unknown`
+ apprise/utils/parse.py:756:26 error[unresolved-attribute] Attribute `group` is not defined on `None` in union `Match[str] | None`
+ apprise/utils/parse.py:757:27 error[unresolved-attribute] Attribute `group` is not defined on `None` in union `Match[str] | None`
+ apprise/utils/parse.py:849:9 error[unsupported-operator] Operator `+=` is not supported between objects of type `str` and `(str & ~AlwaysFalsy) | Unknown | None`

attrs (https://github.com/python-attrs/attrs)
- src/attr/_make.py:262:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `dict[Unknown, Unknown] | Mapping[str, object]`
+ src/attr/_make.py:262:12 error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `Mapping[str, object]`

core (https://github.com/home-assistant/core)
- homeassistant/components/thread/diagnostics.py:209:21 error[unresolved-attribute] Attribute `update` is not defined on `str`, `list[str]`, `list[Unknown]`, `None` in union `str | list[str] | list[Unknown] | dict[Unknown, Unknown] | None`
+ homeassistant/components/thread/diagnostics.py:209:21 error[unresolved-attribute] Attribute `update` is not defined on `str`, `list[str]`, `None` in union `str | list[str] | dict[Unknown, Unknown] | None`
- homeassistant/components/thread/diagnostics.py:212:21 error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `Unknown` on object of type `list[Unknown]`
- homeassistant/components/thread/diagnostics.py:214:36 error[unresolved-attribute] Attribute `keys` is not defined on `str`, `list[str]`, `list[Unknown]`, `None` in union `str | list[str] | list[Unknown] | dict[Unknown, Unknown] | None`
+ homeassistant/components/thread/diagnostics.py:214:36 error[unresolved-attribute] Attribute `keys` is not defined on `str`, `list[str]`, `None` in union `str | list[str] | dict[Unknown, Unknown] | None`
- homeassistant/config_entries.py:1334:17 error[invalid-argument-type] Argument to bound method `ConfigEntriesFlowManager.async_init` is incorrect: Expected `ConfigFlowContext | None`, found `ConfigFlowContext | dict[str, object]`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/llmobs/_experiment.py:2152:28 warning[redundant-cast] Value is already of type `int`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `Prompt | dict[str, str | dict[str, Any] | list[str] | list[dict[str, str]] | list[Message]] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `dict[str, Any] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `dict[str, str] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[Document] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[_SpanLink] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[str] | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/google_genai.py:106:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `str | None`, found `list[ToolDefinition] | Unknown`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `Prompt | dict[str, str | dict[str, Any] | list[str] | list[dict[str, str]] | list[Message]] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `dict[str, Any] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `dict[str, str] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[Message] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[ToolDefinition] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[_SpanLink] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `list[str] | None`, found `Unknown | list[Document]`
- ddtrace/llmobs/_integrations/langchain.py:701:13 error[invalid-argument-type] Argument to function `_annotate_llmobs_span_data` is incorrect: Expected `str | None`, found `Unknown | list[Document]`

dulwich (https://github.com/dulwich/dulwich)
- dulwich/client.py:5239:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["timeout"]` and value of type `int | float` on object of type `dict[str, dict[str | Unknown, str | Unknown] | bool]`
+ dulwich/client.py:5239:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["timeout"]` and value of type `int | float` on object of type `dict[str, dict[str, str | Unknown] | bool]`
- dulwich/client.py:5242:62 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `Sequence[tuple[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | RequestField] | Mapping[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | None`, found `dict[str | Unknown, str | Unknown] | bool`
+ dulwich/client.py:5242:62 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `Sequence[tuple[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | RequestField] | Mapping[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | None`, found `dict[str, str | Unknown] | bool`
- dulwich/client.py:5242:62 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `bytes | IO[Any] | Iterable[bytes | str] | None`, found `dict[str | Unknown, str | Unknown] | bool`
+ dulwich/client.py:5242:62 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `bytes | IO[Any] | Iterable[bytes | str] | None`, found `dict[str, str | Unknown] | bool`
- dulwich/client.py:5244:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["body"]` and value of type `bytes | Iterator[bytes]` on object of type `dict[str, dict[str | Unknown, str | Unknown] | bool]`
+ dulwich/client.py:5244:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["body"]` and value of type `bytes | Iterator[bytes]` on object of type `dict[str, dict[str, str | Unknown] | bool]`
- dulwich/client.py:5245:63 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `Sequence[tuple[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | RequestField] | Mapping[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | None`, found `dict[str | Unknown, str | Unknown] | bool`
+ dulwich/client.py:5245:63 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `Sequence[tuple[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | RequestField] | Mapping[str, str | bytes | tuple[str, str | bytes] | tuple[str, str | bytes, str]] | None`, found `dict[str, str | Unknown] | bool`
- dulwich/client.py:5245:63 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `bytes | IO[Any] | Iterable[bytes | str] | None`, found `dict[str | Unknown, str | Unknown] | bool`
+ dulwich/client.py:5245:63 error[invalid-argument-type] Argument to bound method `RequestMethods.request` is incorrect: Expected `bytes | IO[Any] | Iterable[bytes | str] | None`, found `dict[str, str | Unknown] | bool`
- dulwich/object_store.py:3182:12 error[unsupported-operator] Operator `in` is not supported between objects of type `ObjectID` and `(() -> dict[ObjectID, ObjectID]) | dict[ObjectID, ObjectID] | dict[Unknown, Unknown]`
+ dulwich/object_store.py:3182:12 error[unsupported-operator] Operator `in` is not supported between objects of type `ObjectID` and `(() -> dict[ObjectID, ObjectID]) | dict[ObjectID, ObjectID]`

hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/modeltools.py:3039:13 error[no-matching-overload] No overload of bound method `MutableMapping.update` matches arguments

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/wrapper/_implementations.py:446:13 error[invalid-argument-type] Argument is incorrect: Expected `[email protected]`, found `DictConfig | Unknown`

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/format.py:177:18 error[unresolved-attribute] Attribute `op` is not defined on `Node` in union `Node | Unknown`
+ ibis/expr/format.py:177:18 error[unresolved-attribute] Object of type `Node` has no attribute `op`

meson (https://github.com/mesonbuild/meson)
- mesonbuild/msubprojects.py:332:36 error[unresolved-attribute] Attribute `upper` is not defined on `None` in union `str | None | Unknown`
+ mesonbuild/msubprojects.py:332:36 error[unresolved-attribute] Attribute `upper` is not defined on `None` in union `str | None`
- mesonbuild/wrap/wrap.py:694:28 error[invalid-assignment] Object of type `list[str | None | Unknown]` is not assignable to `list[str]`
+ mesonbuild/wrap/wrap.py:694:28 error[invalid-assignment] Object of type `list[str | None]` is not assignable to `list[str]`

mypy (https://github.com/python/mypy)
- mypy/checker.py:6371:20 error[invalid-return-type] Return type does not match returned value: expected `tuple[list[Type], list[Type]]`, found `tuple[list[Type], list[TypeVarType] | list[Unknown]]`

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/plugins/worksearch/code.py:344:13 error[invalid-argument-type] Argument to bound method `SearchScheme.q_to_solr_params` is incorrect: Expected `list[tuple[str, str]]`, found `list[tuple[str, str] | tuple[str, Unknown | int]] | Unknown`
+ openlibrary/plugins/worksearch/code.py:344:13 error[invalid-argument-type] Argument to bound method `SearchScheme.q_to_solr_params` is incorrect: Expected `list[tuple[str, str]]`, found `list[tuple[str, str] | tuple[str, Unknown | int]]`

paasta (https://github.com/yelp/paasta)
- paasta_tools/instance/kubernetes.py:949:12 error[invalid-return-type] Return type does not match returned value: expected `KubernetesVersionDict`, found `dict[str, Unknown | str | int | ... omitted 3 union elements]`
+ paasta_tools/instance/kubernetes.py:949:12 error[invalid-return-type] Return type does not match returned value: expected `KubernetesVersionDict`, found `dict[str, Unknown | str | int | list[dict[str, Any]] | None]`

pip (https://github.com/pypa/pip)
- src/pip/_vendor/urllib3/connectionpool.py:749:23 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[Unknown, Unknown]`
+ src/pip/_vendor/urllib3/connectionpool.py:749:23 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[str, Unknown]`
- src/pip/_vendor/urllib3/connectionpool.py:906:31 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[Unknown, Unknown]`
+ src/pip/_vendor/urllib3/connectionpool.py:906:31 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[str, Unknown]`
- src/pip/_vendor/urllib3/poolmanager.py:483:27 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Any | Mapping[str, str] | dict[Unknown, Unknown]`
+ src/pip/_vendor/urllib3/poolmanager.py:483:27 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Any | Mapping[str, str] | dict[str, Unknown]`

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/database.py:824:38 error[invalid-argument-type] Argument to function `create_async_engine` is incorrect: Expected `str | URL`, found `URL | dict[str, Any] | dict[Unknown, Unknown] | Any`
+ src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/database.py:824:38 error[invalid-argument-type] Argument to function `create_async_engine` is incorrect: Expected `str | URL`, found `URL | dict[str, Any] | Any`
- src/prefect/tasks.py:956:17 error[invalid-assignment] Invalid subscript assignment with key of type `str | Unknown` and value of type `set[RunInput]` on object of type `dict[str, set[TaskRunResult | FlowRunResult]]`
+ src/prefect/tasks.py:956:17 error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `set[RunInput]` on object of type `dict[str, set[TaskRunResult | FlowRunResult]]`
- src/prefect/tasks.py:1061:17 error[invalid-assignment] Invalid subscript assignment with key of type `str | Unknown` and value of type `set[RunInput]` on object of type `dict[str, set[TaskRunResult | FlowRunResult]]`
+ src/prefect/tasks.py:1061:17 error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `set[RunInput]` on object of type `dict[str, set[TaskRunResult | FlowRunResult]]`

pyodide (https://github.com/pyodide/pyodide)
- pyodide-build/pyodide_build/recipe/graph_builder.py:169:13 error[no-matching-overload] No overload of function `run` matches arguments

rotki (https://github.com/rotki/rotki)
- rotkehlchen/data_import/utils.py:75:21 error[unresolved-attribute] Attribute `append` is not defined on `bool` in union `Unknown | list[Unknown] | bool`

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/generation/metrics.py:75:31 error[unresolved-attribute] Attribute `__name__` is not defined on `(MetricContext, /) -> int | float` in union `((MetricContext, /) -> int | float) | Unknown`
+ src/schemathesis/generation/metrics.py:75:31 error[unresolved-attribute] Object of type `(MetricContext, /) -> int | float` has no attribute `__name__`
- src/schemathesis/generation/metrics.py:82:31 error[unresolved-attribute] Attribute `__name__` is not defined on `(MetricContext, /) -> int | float` in union `((MetricContext, /) -> int | float) | Unknown`
+ src/schemathesis/generation/metrics.py:82:31 error[unresolved-attribute] Object of type `(MetricContext, /) -> int | float` has no attribute `__name__`
- src/schemathesis/generation/metrics.py:95:43 error[unresolved-attribute] Attribute `__name__` is not defined on `(MetricContext, /) -> int | float` in union `((MetricContext, /) -> int | float) | Unknown`
+ src/schemathesis/generation/metrics.py:95:43 error[unresolved-attribute] Object of type `(MetricContext, /) -> int | float` has no attribute `__name__`
- src/schemathesis/generation/metrics.py:96:44 error[unresolved-attribute] Attribute `__name__` is not defined on `(MetricContext, /) -> int | float` in union `((MetricContext, /) -> int | float) | Unknown`
+ src/schemathesis/generation/metrics.py:96:44 error[unresolved-attribute] Object of type `(MetricContext, /) -> int | float` has no attribute `__name__`

scipy (https://github.com/scipy/scipy)
- scipy/stats/tests/common_tests.py:72:9 error[no-matching-overload] No overload of function `assert_allclose` matches arguments

setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/command/build_ext.py:435:13 error[invalid-assignment] Object of type `object` is not assignable to attribute `runtime_library_dirs` of type `list[str] | list[Unknown]`
+ setuptools/_distutils/command/build_ext.py:435:13 error[invalid-assignment] Object of type `object` is not assignable to attribute `runtime_library_dirs` of type `list[str]`
- setuptools/_distutils/compilers/C/base.py:446:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[str, list[tuple[str] | tuple[str, str | None]], list[str]]`, found `tuple[str | None, list[tuple[str] | tuple[str, str | None]] | Unknown, list[str] | Unknown]`
+ setuptools/_distutils/compilers/C/base.py:446:16 error[invalid-return-type] Return type does not match returned value: expected `tuple[str, list[tuple[str] | tuple[str, str | None]], list[str]]`, found `tuple[str | None, list[tuple[str] | tuple[str, str | None]], list[str]]`

strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/schema/schema.py:858:33 error[invalid-argument-type] Argument to function `subscribe` is incorrect: Expected `((...) -> Any) | None`, found `Unknown | MiddlewareManager | type[ExecutionContext] | None | dict[str, Any]`
+ strawberry/schema/schema.py:858:33 error[invalid-argument-type] Argument to function `subscribe` is incorrect: Expected `((...) -> Any) | None`, found `MiddlewareManager | type[ExecutionContext] | None | dict[str, Any]`
- strawberry/schema/schema.py:858:33 error[invalid-argument-type] Argument to function `subscribe` is incorrect: Expected `((...) -> Any) | None`, found `Unknown | MiddlewareManager | type[ExecutionContext] | None | dict[str, Any]`
+ strawberry/schema/schema.py:858:33 error[invalid-argument-type] Argument to function `subscribe` is incorrect: Expected `int`, found `MiddlewareManager | type[ExecutionContext] | None | dict[str, Any]`
- strawberry/schema/schema.py:858:33 error[invalid-argument-type] Argument to function `subscribe` is incorrect: Expected `int`, found `Unknown | MiddlewareManager | type[ExecutionContext] | None | dict[str, Any]`

urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/connectionpool.py:749:23 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[Unknown, Unknown]`
+ src/urllib3/connectionpool.py:749:23 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[str, Unknown]`
- src/urllib3/connectionpool.py:905:31 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[Unknown, Unknown]`
+ src/urllib3/connectionpool.py:905:31 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Mapping[str, str] | dict[str, Unknown]`
- src/urllib3/poolmanager.py:483:27 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Any | Mapping[str, str] | dict[Unknown, Unknown]`
+ src/urllib3/poolmanager.py:483:27 error[unresolved-attribute] Attribute `copy` is not defined on `Mapping[str, str]` in union `Any | Mapping[str, str] | dict[str, Unknown]`

vision (https://github.com/pytorch/vision)
- setup.py:285:20 error[unresolved-attribute] Attribute `copy` is not defined on `str` in union `str | list[str] | list[Unknown]`
+ setup.py:285:20 error[unresolved-attribute] Attribute `copy` is not defined on `str` in union `str | list[str]`
- setup.py:286:20 error[unresolved-attribute] Attribute `copy` is not defined on `str` in union `str | list[str] | list[Unknown]`
+ setup.py:286:20 error[unresolved-attribute] Attribute `copy` is not defined on `str` in union `str | list[str]`

xarray (https://github.com/pydata/xarray)
- xarray/tests/test_concat.py:292:16 error[no-matching-overload] No overload of function `concat` matches arguments
- xarray/tests/test_concat.py:305:14 error[no-matching-overload] No overload of function `concat` matches arguments

Full report with detailed diff (timing results)

@carljm carljm marked this pull request as ready for review June 11, 2026 00:10
@astral-sh-bot astral-sh-bot Bot requested a review from dhruvmanila June 11, 2026 00:10
let db = self.db();

let elements = operations
.into_iter()
.with_position()
.map(|(position, item)| {
let (ty, range) = infer_ty(self, item);
let peer_ty = if done || !track_peer_types || !needs_peer_type(&item) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need both needs_peer_type and track_peer_types? Could needs_peer_type just always return false, to implement the same behavior? Or even, make it optional?

@carljm carljm merged commit 4fb0547 into main Jun 11, 2026
59 checks passed
@carljm carljm deleted the cjm/3574-3693-collection-literal-peer-context branch June 11, 2026 04:22
Comment on lines +10550 to +10551
tcx.annotation
.is_none_or(|annotation| annotation == Type::Dynamic(DynamicType::UnspecializedTypeVar))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can also write this as a simple matches! FWIW

Suggested change
tcx.annotation
.is_none_or(|annotation| annotation == Type::Dynamic(DynamicType::UnspecializedTypeVar))
matches!(
tcx.annotation,
Some(Type::Dynamic(DynamicType::UnspecializedTypeVar)) | None
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair, but IMO not worth a follow-up PR; I think it's kind of a toss-up which is more readable tbh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh yeah agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invalid-argument-type false positive: generic type parameter resolved to Unknown after or expression Use type context for binary operations

4 participants