Skip to content

Comments

[ty] Avoid literal promotion for covariant declared types#23186

Open
ibraheemdev wants to merge 1 commit intomainfrom
ibraheem/covariant-literal-promotion
Open

[ty] Avoid literal promotion for covariant declared types#23186
ibraheemdev wants to merge 1 commit intomainfrom
ibraheem/covariant-literal-promotion

Conversation

@ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Feb 9, 2026

Avoid literal promotion (and Unknown widening) for elements in covariant position in their declared type, e.g.,

_: Iterable[int] = reveal_type([1, 2, 3]) # list[Literal[1, 2, 3]]

for _ in reveal_type([1, 2, 3]): # list[Literal[1, 2, 3]]
    ...

reveal_type(frozenset([1, 2, 3]))  # Revealed type: `frozenset[Literal[1, 2, 3]]`

Resolves astral-sh/ty#2280, resolves astral-sh/ty#2441.

@ibraheemdev ibraheemdev added the ty Multi-file analysis & type inference label Feb 9, 2026
@ibraheemdev ibraheemdev requested a review from dcreager as a code owner February 9, 2026 21:55
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 9, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 9, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 13 14 111
type-assertion-failure 9 3 18
unsupported-operator 4 4 21
possibly-missing-attribute 1 15 12
unresolved-attribute 15 0 0
invalid-assignment 0 4 7
no-matching-overload 0 11 0
unused-type-ignore-comment 10 1 0
unsupported-base 4 0 0
invalid-key 0 0 1
invalid-return-type 1 0 0
possibly-unresolved-reference 0 1 0
Total 57 53 170

Full report with detailed diff (timing results)

@ibraheemdev ibraheemdev force-pushed the ibraheem/covariant-literal-promotion branch from 0a8d74a to 46aac79 Compare February 9, 2026 22:06
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 9, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing ibraheem/covariant-literal-promotion (3bf92a5) with main (20a1741)

Summary

✅ 24 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 Feb 9, 2026

mypy_primer results

Changes were detected when running on open source projects
attrs (https://github.com/python-attrs/attrs)
- src/attr/validators.py:175:24: error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `(Overload[(pattern: str | Pattern[str], string: str, flags: int = 0) -> Match[str] | None, (pattern: bytes | Pattern[bytes], string: Buffer, flags: int = 0) -> Match[bytes] | None] & ~AlwaysTruthy & ~AlwaysFalsy) | (str & ~AlwaysFalsy)` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- Found 633 diagnostics
+ Found 632 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/fetch_strategy.py:1500:42: error[invalid-argument-type] Argument to function `quote` is incorrect: Expected `list[str]`, found `set[Unknown]`
+ lib/spack/spack/fetch_strategy.py:1500:42: error[invalid-argument-type] Argument to function `quote` is incorrect: Expected `list[str]`, found `set[@Todo]`
- lib/spack/spack/test/buildtask.py:22:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `PackageBase`, found `Unknown | None | str`
+ lib/spack/spack/test/buildtask.py:22:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `PackageBase`, found `None | Literal["abc"]`
- lib/spack/spack/test/cmd/deprecate.py:90:41: error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `Unknown | Spec` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
+ lib/spack/spack/test/cmd/deprecate.py:90:41: error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `Spec | Unknown` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- lib/spack/spack/test/provider_index.py:79:23: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Spec] | None`, found `list[str]`
+ lib/spack/spack/test/provider_index.py:79:23: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Spec] | None`, found `list[Literal["mpich"]]`
- lib/spack/spack/vendor/attr/validators.py:186:25: error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `(Overload[(pattern: str | Pattern[str], string: str, flags: int = 0) -> Match[str] | None, (pattern: bytes | Pattern[bytes], string: Buffer, flags: int = 0) -> Match[bytes] | None] & ~AlwaysTruthy & ~AlwaysFalsy) | (str & ~AlwaysFalsy)` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
+ lib/spack/spack/vendor/jinja2/nodes.py:215:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_ctx]`, found `Iterator[Node]`
+ lib/spack/spack/vendor/jinja2/nodes.py:226:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_lineno]`, found `Iterator[Node]`
+ lib/spack/spack/vendor/jinja2/nodes.py:235:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_environment]`, found `Iterator[Node]`
- Found 4365 diagnostics
+ Found 4367 diagnostics

asynq (https://github.com/quora/asynq)
- asynq/tests/test_tools.py:129:30: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `((Unknown | int, /) -> Any) | None`, found `list[Unknown | int]`
+ asynq/tests/test_tools.py:129:30: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `((Literal[1], /) -> Any) | None`, found `list[Unknown | int]`
- asynq/tests/test_typing.py:62:34: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `((Unknown | int | Sized, /) -> Any) | None`, found `def len(obj: Sized, /) -> int`
+ asynq/tests/test_typing.py:62:34: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `((Literal[1, 2] | Sized, /) -> Any) | None`, found `def len(obj: Sized, /) -> int`

werkzeug (https://github.com/pallets/werkzeug)
- tests/test_wrappers.py:1096:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[str]`
+ tests/test_wrappers.py:1096:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[Literal["foo", "bar", "baz"]]`
- tests/test_wrappers.py:1101:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[str]`
+ tests/test_wrappers.py:1101:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[Literal["foo", "bar", "baz"]]`
- tests/test_wrappers.py:1105:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[str]`
+ tests/test_wrappers.py:1105:28: error[invalid-argument-type] Argument to bound method `writelines` is incorrect: Expected `Iterable[bytes]`, found `list[Literal["bar", "baz"]]`

jinja (https://github.com/pallets/jinja)
+ src/jinja2/nodes.py:217:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_ctx]`, found `Iterator[Node]`
+ src/jinja2/nodes.py:228:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_lineno]`, found `Iterator[Node]`
+ src/jinja2/nodes.py:237:25: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@set_environment]`, found `Iterator[Node]`
- Found 179 diagnostics
+ Found 182 diagnostics

pip (https://github.com/pypa/pip)
+ src/pip/_internal/req/req_uninstall.py:131:48: error[invalid-argument-type] Argument to function `walk` is incorrect: Argument type `Sized` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr`
- src/pip/_internal/req/req_uninstall.py:132:42: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Unknown | Sized`
+ src/pip/_internal/req/req_uninstall.py:132:42: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Sized`
- src/pip/_internal/req/req_uninstall.py:133:40: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Unknown | Sized`
+ src/pip/_internal/req/req_uninstall.py:133:40: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Sized`
- src/pip/_internal/req/req_uninstall.py:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | Sized` and `LiteralString`
+ src/pip/_internal/req/req_uninstall.py:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Sized` and `LiteralString`
- Found 629 diagnostics
+ Found 630 diagnostics

pytest (https://github.com/pytest-dev/pytest)
- testing/test_assertrewrite.py:140:28: error[unsupported-operator] Operator `<=` is not supported between objects of type `tuple[Literal[3], Literal[0]]` and `Unknown | tuple[int | None, int | None]`
+ testing/test_assertrewrite.py:140:28: error[unsupported-operator] Operator `<=` is not supported between objects of type `tuple[Literal[3], Literal[0]]` and `tuple[int | None, int | None]`
- testing/test_assertrewrite.py:140:38: error[unsupported-operator] Operator `<=` is not supported between objects of type `Unknown | tuple[int | None, int | None]` and `tuple[Literal[6], Literal[3]]`
+ testing/test_assertrewrite.py:140:38: error[unsupported-operator] Operator `<=` is not supported between objects of type `tuple[int | None, int | None]` and `tuple[Literal[6], Literal[3]]`

sockeye (https://github.com/awslabs/sockeye)
- sockeye/output_handler.py:254:80: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown | list[str]]`, found `list[list[str]] | None`
+ sockeye/output_handler.py:254:80: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[list[str]]`, found `list[list[str]] | None`

dulwich (https://github.com/dulwich/dulwich)
- dulwich/contrib/swift.py:161:35: error[invalid-argument-type] Argument to bound method `add_todo` is incorrect: Expected `Iterable[tuple[ObjectID, bytes | None, int | None, bool]]`, found `list[tuple[Unknown | bytes, None, None, bool]]`
+ dulwich/contrib/swift.py:161:35: error[invalid-argument-type] Argument to bound method `add_todo` is incorrect: Expected `Iterable[tuple[ObjectID, bytes | None, int | None, bool]]`, found `list[tuple[Unknown | bytes, None, None, Literal[False]]]`
- dulwich/object_store.py:2921:31: error[invalid-argument-type] Argument to bound method `add_todo` is incorrect: Expected `Iterable[tuple[ObjectID, bytes | None, int | None, bool]]`, found `list[tuple[Unknown | bytes, None, Unknown | int, bool]]`
+ dulwich/object_store.py:2921:31: error[invalid-argument-type] Argument to bound method `add_todo` is incorrect: Expected `Iterable[tuple[ObjectID, bytes | None, int | None, bool]]`, found `list[tuple[Unknown | bytes, None, Unknown | int, Literal[False]]]`

porcupine (https://github.com/Akuli/porcupine)
- porcupine/pluginmanager.py:133:49: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `Unknown | str`
- Found 25 diagnostics
+ Found 24 diagnostics

ignite (https://github.com/pytorch/ignite)
- tests/ignite/metrics/nlp/test_bleu.py:26:29: error[invalid-argument-type] Argument to bound method `_corpus_bleu` is incorrect: Expected `Sequence[Sequence[Sequence[Any]]]`, found `list[list[int]]`
+ tests/ignite/metrics/nlp/test_bleu.py:26:29: error[invalid-argument-type] Argument to bound method `_corpus_bleu` is incorrect: Expected `Sequence[Sequence[Sequence[Any]]]`, found `list[list[Literal[0]]]`

PyGithub (https://github.com/PyGithub/PyGithub)
- github/Requester.py:899:57: error[invalid-argument-type] Argument to bound method `__hostnameHasDomain` is incorrect: Expected `str | list[str]`, found `Unknown | list[Unknown | str] | list[Unknown | str | None]`
+ github/Requester.py:899:57: error[invalid-argument-type] Argument to bound method `__hostnameHasDomain` is incorrect: Expected `str | list[str]`, found `Unknown | list[Unknown | str] | list[str | None]`

nox (https://github.com/wntrblm/nox)
+ nox/manifest.py:181:25: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy)]`, found `Unknown | Sequence[str]`
- Found 24 diagnostics
+ Found 25 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- tornado/test/httpclient_test.py:521:17: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["User-Agent"]` and value of type `Unknown | str | bytes` on object of type `HTTPHeaders`
+ tornado/test/httpclient_test.py:521:17: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["User-Agent"]` and value of type `Literal["MyUserAgent", b"MyUserAgent"]` on object of type `HTTPHeaders`

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | ((dict[str, int | float | str | ... omitted 3 union elements], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
+ pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | ((dict[str, Divergent], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
- pydantic/fields.py:949: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:949: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:989: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:989: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:1032: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:1032: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:1072: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:1072: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:1115: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:1115: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:1154: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:1154: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:1194: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:1194: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:1573: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`
+ pydantic/fields.py:1573: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`

pandera (https://github.com/pandera-dev/pandera)
- tests/hypotheses/test_hypotheses.py:281:33: error[invalid-argument-type] Argument to bound method `two_sample_ttest` is incorrect: Expected `str`, found `Unknown | str | int | None`
+ tests/hypotheses/test_hypotheses.py:281:33: error[invalid-argument-type] Argument to bound method `two_sample_ttest` is incorrect: Expected `str`, found `Literal["foo", "bar", 1, 2, 3] | None`
- tests/pandas/test_checks.py:353:17: error[invalid-argument-type] Argument to function `reshape_failure_cases` is incorrect: Expected `DataFrame | Series[Any]`, found `Unknown | int | str | ... omitted 3 union elements`
+ tests/pandas/test_checks.py:353:17: error[invalid-argument-type] Argument to function `reshape_failure_cases` is incorrect: Expected `DataFrame | Series[Any]`, found `Literal[1, "foobar"] | float | dict[Unknown | str, Unknown | str] | list[int]`

artigraph (https://github.com/artigraph/artigraph)
- tests/arti/types/test_types.py:100:51: error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `frozenset[Unknown | int | float] | list[Unknown | int | float] | tuple[Unknown | int | float, ...]`
+ tests/arti/types/test_types.py:100:51: error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `frozenset[float] | list[int | float] | tuple[float, ...]`

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- test/mitmproxy/test_http.py:821:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[tuple[bytes, bytes]]`, found `list[tuple[bytes, str]]`
+ test/mitmproxy/test_http.py:821:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[tuple[bytes, bytes]]`, found `list[tuple[Literal[b"Host"], Literal["not-bytes"]]]`

optuna (https://github.com/optuna/optuna)
+ optuna/study/_tell.py:176:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[TrialState, list[int | float] | None, str | None]`, found `tuple[TrialState, None | list[float], None | str]`
- Found 569 diagnostics
+ Found 570 diagnostics

mkdocs (https://github.com/mkdocs/mkdocs)
- mkdocs/tests/structure/page_tests.py:670:41: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `Unknown | dict[Unknown | str, Unknown | str] | str | None | dict[Unknown, Unknown]`
+ mkdocs/tests/structure/page_tests.py:670:41: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `dict[Unknown | str, Unknown | str] | str | None | dict[Unknown, Unknown]`
- mkdocs/tests/structure/page_tests.py:693:41: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `Unknown | dict[Unknown | str, Unknown | str] | str`
+ mkdocs/tests/structure/page_tests.py:693:41: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `dict[Unknown | str, Unknown | str] | str`
- mkdocs/tests/structure/page_tests.py:715:17: error[invalid-assignment] Object of type `Unknown | str | None` is not assignable to attribute `edit_uri` of type `weak_property`
+ mkdocs/tests/structure/page_tests.py:715:17: error[invalid-assignment] Object of type `str | None` is not assignable to attribute `edit_uri` of type `weak_property`

vision (https://github.com/pytorch/vision)
- test/test_transforms_v2.py:6533:42: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | float]`, found `Unknown | None | int | list[Unknown | int]`
+ test/test_transforms_v2.py:6533:42: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | float]`, found `None | Literal[1] | list[Unknown | int]`

trio (https://github.com/python-trio/trio)
+ src/trio/_core/_tests/test_tutil.py:10:42: error[invalid-argument-type] Argument to function `check_sequence_matches` is incorrect: Expected `Iterable[Literal[1, 2, 3, 4] | set[Literal[1, 2, 3, 4]]]`, found `list[Literal[1, 4] | set[Unknown | int]]`
+ src/trio/_core/_tests/test_tutil.py:11:42: error[invalid-argument-type] Argument to function `check_sequence_matches` is incorrect: Expected `Iterable[Literal[1, 3, 2, 4] | set[Literal[1, 3, 2, 4]]]`, found `list[Literal[1, 4] | set[Unknown | int]]`
+ src/trio/_core/_tests/test_tutil.py:13:46: error[invalid-argument-type] Argument to function `check_sequence_matches` is incorrect: Expected `Iterable[Literal[1, 2, 4, 3] | set[Literal[1, 2, 4, 3]]]`, found `list[Literal[1, 4] | set[Unknown | int]]`
- Found 471 diagnostics
+ Found 474 diagnostics

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/catalog/utils/__init__.py:32:18: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- openlibrary/catalog/utils/__init__.py:132:17: warning[possibly-missing-attribute] Attribute `search` may be missing on object of type `Unknown | str`
+ openlibrary/plugins/worksearch/schemes/works.py:288:18: error[unsupported-operator] Operator `&` is not supported between objects of type `Unknown | frozenset[Literal["title", "publisher", "oclc", "lccn", "contributor", ... omitted 7 literals]]` and `set[str]`
- Found 1128 diagnostics
+ Found 1127 diagnostics

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- pymongo/asynchronous/auth.py:365:69: error[invalid-assignment] Object of type `dict[str, ((credentials: MongoCredential, conn: AsyncConnection) -> CoroutineType[Any, Any, None]) | ((credentials: MongoCredential, conn: AsyncConnection, reauthenticate: bool) -> CoroutineType[Any, Any, Mapping[str, Any] | None]) | partial[CoroutineType[Any, Any, None]]]` is not assignable to `Mapping[str, (...) -> Coroutine[Any, Any, None]]`
+ pymongo/asynchronous/auth.py:365:69: error[invalid-assignment] Object of type `dict[str, (def _authenticate_gssapi(credentials: MongoCredential, conn: AsyncConnection) -> CoroutineType[Any, Any, None]) | (def _authenticate_x509(credentials: MongoCredential, conn: AsyncConnection) -> CoroutineType[Any, Any, None]) | (def _authenticate_aws(credentials: MongoCredential, conn: AsyncConnection) -> CoroutineType[Any, Any, None]) | ... omitted 4 union elements]` is not assignable to `Mapping[str, (...) -> Coroutine[Any, Any, None]]`
- pymongo/synchronous/auth.py:360:48: error[invalid-assignment] Object of type `dict[str, ((credentials: MongoCredential, conn: Connection) -> None) | ((credentials: MongoCredential, conn: Connection, reauthenticate: bool) -> Mapping[str, Any] | None) | partial[None]]` is not assignable to `Mapping[str, (...) -> None]`
+ pymongo/synchronous/auth.py:360:48: error[invalid-assignment] Object of type `dict[str, (def _authenticate_gssapi(credentials: MongoCredential, conn: Connection) -> None) | (def _authenticate_x509(credentials: MongoCredential, conn: Connection) -> None) | (def _authenticate_aws(credentials: MongoCredential, conn: Connection) -> None) | ... omitted 4 union elements]` is not assignable to `Mapping[str, (...) -> None]`

xarray (https://github.com/pydata/xarray)
+ xarray/core/treenode.py:866:26: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[NodePath, tuple[AnyNamedNode@group_subtrees, ...] & ~AlwaysFalsy]`, found `tuple[NodePath, tuple[AnyNamedNode@group_subtrees, ...]]`
+ xarray/tests/test_backends.py:7643:52: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_concat.py:1462:38: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_concat.py:1467:38: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_interp.py:521:53: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_merge.py:671:48: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_merge.py:676:48: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_missing.py:340:67: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ xarray/tests/test_missing.py:343:76: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- xarray/tests/test_plot.py:3249:9: error[no-matching-overload] No overload matches arguments
- Found 1718 diagnostics
+ Found 1726 diagnostics

apprise (https://github.com/caronc/apprise)
- apprise/plugins/fortysixelks.py:161:23: error[invalid-assignment] Object of type `list[(str & ~Literal[""]) | None]` is not assignable to `Iterable[str] | None`
+ apprise/plugins/fortysixelks.py:161:23: error[invalid-assignment] Object of type `list[(LiteralString & ~Literal[""]) | None]` is not assignable to `Iterable[str] | None`

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/load_tool.py:176:33: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | str` and value of type `str` on object of type `MutableSequence[MutableMapping[str, None | int | str | ... omitted 3 union elements] | str | int]`
- Found 511 diagnostics
+ Found 510 diagnostics

meson (https://github.com/mesonbuild/meson)
- mesonbuild/interpreter/interpreter.py:2675:36: error[invalid-key] TypedDict `ConfigureFile` can only be subscripted with a string literal key, got key of type `str`
+ mesonbuild/interpreter/interpreter.py:2675:36: error[invalid-key] Unknown key "copy" for TypedDict `ConfigureFile`: Unknown key "copy"
+ mesonbuild/modules/gnome.py:2109:70: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- mesonbuild/modules/i18n.py:430:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[str | BuildTarget | CustomTarget | ... omitted 4 union elements]`, found `list[Program | None | str]`
+ mesonbuild/modules/i18n.py:430:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[str | BuildTarget | CustomTarget | ... omitted 4 union elements]`, found `list[Program | None | Literal["-o", "@OUTPUT@", "@INPUT@"]]`
- unittests/allplatformstests.py:2506:49: error[invalid-argument-type] Argument to function `detect_compiler_for` is incorrect: Expected `Literal["c", "cpp", "cuda", "fortran", "d", ... omitted 11 literals]`, found `Unknown | str`

pycryptodome (https://github.com/Legrandin/pycryptodome)
- lib/Crypto/PublicKey/RSA.py:368:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | DerObject] | None`, found `list[int | Unknown | IntegerBase]`
+ lib/Crypto/PublicKey/RSA.py:368:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | DerObject] | None`, found `list[Literal[0] | Unknown | IntegerBase]`
- lib/Crypto/SelfTest/Util/test_asn1.py:329:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | DerObject] | None`, found `list[int | DerInteger | bytes]`
+ lib/Crypto/SelfTest/Util/test_asn1.py:329:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[int | DerObject] | None`, found `list[Literal[1] | DerInteger | bytes]`

altair (https://github.com/vega/altair)
- altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `bool`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `bool`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `Literal["vega-lite", "vega"]`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `Literal["vega-lite", "vega"]`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `list[str] | None`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `list[str] | None`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `dict[str, Any] | None`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4172:47: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `dict[str, Any] | None`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `bool`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `bool`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `Literal["vega-lite", "vega"]`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `Literal["vega-lite", "vega"]`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `list[str] | None`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `list[str] | None`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`
- altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `dict[str, Any] | None`, found `bool | str | list[str] | ... omitted 3 union elements`
+ altair/vegalite/v6/api.py:4173:32: error[invalid-argument-type] Argument to bound method `to_dict` is incorrect: Expected `dict[str, Any] | None`, found `bool | Literal["vega-lite", "vega"] | list[str] | ... omitted 3 union elements`

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/linear_model/tests/test_coordinate_descent.py:1062:20: warning[possibly-missing-attribute] Attribute `dot` may be missing on object of type `Unknown | float64 | floating[_32Bit]`
+ sklearn/linear_model/tests/test_coordinate_descent.py:1062:20: error[unresolved-attribute] Object of type `float64 | floating[_32Bit]` has no attribute `dot`
- sklearn/model_selection/tests/test_search.py:1603:37: warning[possibly-unresolved-reference] Name `correct_score` used when possibly not defined
+ sklearn/utils/tests/test_estimator_checks.py:1548:27: warning[unsupported-base] Unsupported class base with type `<class 'MinimalTransformer'> | <class 'MinimalRegressor'> | <class 'MinimalClassifier'>`

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-aws/tests/experimental/test_decorators.py:255:41: error[invalid-argument-type] Argument to function `ecs` is incorrect: Expected `Sequence[str] | None`, found `list[str | int]`
+ src/integrations/prefect-aws/tests/experimental/test_decorators.py:255:41: error[invalid-argument-type] Argument to function `ecs` is incorrect: Expected `Sequence[str] | None`, found `list[Literal["valid", 123]]`
- src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler] | Coroutine[Any, Any, T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]]`
+ src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `Unknown | Coroutine[Any, Any, Unknown]`

pywin32 (https://github.com/mhammond/pywin32)
- com/win32com/test/testPyComTest.py:576:17: error[invalid-assignment] Object of type `int` is not assignable to attribute `int_value` on type `Unknown | TestStruct1`
+ com/win32com/test/testPyComTest.py:576:17: error[unresolved-attribute] Unresolved attribute `int_value` on type `TestStruct1`
- com/win32com/test/testPyComTest.py:615:17: error[invalid-assignment] Object of type `float` is not assignable to attribute `id` on type `Unknown | TestStruct3`
+ com/win32com/test/testPyComTest.py:615:17: error[unresolved-attribute] Unresolved attribute `id` on type `TestStruct3`
- com/win32com/test/testPyComTest.py:616:17: error[invalid-assignment] Object of type `tuple[Unknown | tuple[Unknown | tuple[Unknown | int | float, ...], ...], ...]` is not assignable to attribute `array_of_double` on type `Unknown | TestStruct3`
+ com/win32com/test/testPyComTest.py:616:17: error[unresolved-attribute] Unresolved attribute `array_of_double` on type `TestStruct3`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/debugging/_redaction.py:16:5: error[unsupported-operator] Operator `|` is not supported between objects of type `frozenset[Unknown | str]` and `Unknown | EnvVariable[set[Unknown]]`
+ ddtrace/debugging/_redaction.py:16:5: error[unsupported-operator] Operator `|` is not supported between objects of type `frozenset[Literal["2fa", "accesstoken", "aiohttpsession", "apikey", "apisecret", ... omitted 80 literals]]` and `Unknown | EnvVariable[set[Unknown]]`
- scripts/freshvenvs.py:344:69: error[invalid-argument-type] Argument to function `_versions_fully_cover_bounds` is incorrect: Expected `list[str]`, found `list[Unknown | Version] & ~AlwaysFalsy`
+ scripts/freshvenvs.py:344:69: error[invalid-argument-type] Argument to function `_versions_fully_cover_bounds` is incorrect: Expected `list[str]`, found `list[Version] & ~AlwaysFalsy`

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/cli/mz_workload_anonymize.py:251:13: error[no-matching-overload] No overload of bound method `join` matches arguments
- misc/python/materialize/feature_benchmark/benchmark.py:119:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action | Unknown`
+ misc/python/materialize/feature_benchmark/benchmark.py:119:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action`
- misc/python/materialize/feature_benchmark/benchmark.py:131:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action | Unknown`
+ misc/python/materialize/feature_benchmark/benchmark.py:131:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action`
- misc/python/materialize/feature_benchmark/benchmark.py:142:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action | Unknown`
+ misc/python/materialize/feature_benchmark/benchmark.py:142:17: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `None | Action`
- Found 535 diagnostics
+ Found 534 diagnostics

pandas (https://github.com/pandas-dev/pandas)
- pandas/tests/frame/methods/test_join.py:422:27: error[invalid-argument-type] Argument to bound method `join` is incorrect: Expected `Literal["left", "right", "inner", "outer", "cross", "left_anti", "right_anti"]`, found `Unknown | str`
- pandas/tests/frame/methods/test_shift.py:741:22: error[invalid-argument-type] Argument to bound method `shift` is incorrect: Expected `int | Sequence[int]`, found `list[str]`
+ pandas/tests/frame/methods/test_shift.py:741:22: error[invalid-argument-type] Argument to bound method `shift` is incorrect: Expected `int | Sequence[int]`, found `list[Literal["s"]]`
+ pandas/tests/groupby/test_api.py:112:16: error[unsupported-operator] Operator `&` is not supported between objects of type `frozenset[Literal["all", "any", "corrwith", "count", "first", ... omitted 17 literals]]` and `frozenset[Literal["bfill", "cumcount", "cummax", "cummin", "cumprod", ... omitted 7 literals]]`
+ pandas/tests/groupby/test_api.py:113:16: error[unsupported-operator] Operator `&` is not supported between objects of type `frozenset[Literal["all", "any", "corrwith", "count", "first", ... omitted 17 literals]]` and `frozenset[Literal["agg", "aggregate", "apply", "boxplot", "corr", ... omitted 23 literals]]`
+ pandas/tests/groupby/test_api.py:114:16: error[unsupported-operator] Operator `&` is not supported between objects of type `frozenset[Literal["bfill", "cumcount", "cummax", "cummin", "cumprod", ... omitted 7 literals]]` and `frozenset[Literal["agg", "aggregate", "apply", "boxplot", "corr", ... omitted 23 literals]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:27:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:27:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:28:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:28:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:37:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:37:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:38:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:38:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:58:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:58:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_repeat.py:59:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `Unknown | DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/datetimes/methods/test_repeat.py:59:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `DatetimeIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/datetimes/methods/test_round.py:84:54: error[invalid-argument-type] Argument to bound method `round` is incorrect: Expected `int`, found `Unknown | str`
+ pandas/tests/indexes/datetimes/methods/test_round.py:84:54: error[invalid-argument-type] Argument to bound method `round` is incorrect: Expected `int`, found `Literal["us", "ns"]`
- pandas/tests/indexes/timedeltas/methods/test_repeat.py:15:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `Unknown | TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/timedeltas/methods/test_repeat.py:15:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/timedeltas/methods/test_repeat.py:16:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `Unknown | TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/timedeltas/methods/test_repeat.py:16:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/timedeltas/methods/test_repeat.py:33:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `Unknown | TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/timedeltas/methods/test_repeat.py:33:35: error[invalid-argument-type] Argument to function `assert_index_equal` is incorrect: Expected `Index`, found `TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexes/timedeltas/methods/test_repeat.py:34:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `Unknown | TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
+ pandas/tests/indexes/timedeltas/methods/test_repeat.py:34:20: warning[possibly-missing-attribute] Attribute `freq` may be missing on object of type `TimedeltaIndex | ndarray[tuple[int], dtype[Unknown]]`
- pandas/tests/indexing/multiindex/test_multiindex.py:230:41: error[invalid-argument-type] Argument to bound method `from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `list[tuple[str, str, str] | int | float]`
+ pandas/tests/indexing/multiindex/test_multiindex.py:230:41: error[invalid-argument-type] Argument to bound method `from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `list[tuple[Literal["a"], Literal["b"], Literal["c"]] | int | float | tuple[Literal["d"], Literal[""], Literal[""]]]`
- pandas/tests/indexing/multiindex/test_slice.py:524:24: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `int | Literal["index", "columns", "rows"] | None`, found `Unknown | int | str`
+ pandas/tests/indexing/multiindex/test_slice.py:524:24: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `int | Literal["index", "columns", "rows"] | None`, found `Literal[-1, 2, "foo"]`
- pandas/tests/io/json/test_pandas.py:490:39: error[invalid-argument-type] Argument to bound method `to_json` is incorrect: Expected `Literal["split", "records", "index", "table", "columns", "values"] | None`, found `Unknown | str`
- pandas/tests/io/parser/test_read_fwf.py:222:34: error[invalid-argument-type] Argument to function `read_fwf` is incorrect: Expected `Sequence[tuple[int, int]] | str | None`, found `list[tuple[str, int]]`
+ pandas/tests/io/parser/test_read_fwf.py:222:34: error[invalid-argument-type] Argument to function `read_fwf` is incorrect: Expected `Sequence[tuple[int, int]] | str | None`, found `list[tuple[Literal["a"], Literal[1]]]`
- pandas/tests/resample/test_datetime_index.py:931:39: error[invalid-argument-type] Argument to bound method `resample` is incorrect: Expected `str | date | datetime64[date | int | None] | ... omitted 3 union elements`, found `Unknown | str | Timestamp | None`
+ pandas/tests/resample/test_datetime_index.py:931:39: error[invalid-argument-type] Argument to bound method `resample` is incorrect: Expected `str | date | datetime64[date | int | None] | ... omitted 3 union elements`, found `Literal["epoch", "start", "start_day"] | Timestamp | None`
- pandas/tests/reshape/merge/test_merge.py:1517:64: error[invalid-argument-type] Argument to function `merge` is incorrect: Expected `Literal["left", "right", "inner", "outer", "cross", "left_anti", "right_anti"]`, found `Unknown | str`
- pandas/tests/reshape/test_crosstab.py:477:77: error[invalid-argument-type] Argument to function `crosstab` is incorrect: Expected `bool | Literal[0, 1, "all", "index", "columns"]`, found `Unknown | bool | str`
- pandas/tests/scalar/period/test_arithmetic.py:138:21: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | YearBegin | MonthBegin | ... omitted 3 union elements` and `Period`
+ pandas/tests/scalar/period/test_arithmetic.py:138:21: error[unsupported-operator] Operator `+` is not supported between objects of type `YearBegin | MonthBegin | Minute | timedelta64[timedelta | int | None] | timedelta` and `Period`
- pandas/tests/scalar/period/test_arithmetic.py:167:21: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | YearBegin | MonthBegin | ... omitted 3 union elements` and `Period`
+ pandas/tests/scalar/period/test_arithmetic.py:167:21: error[unsupported-operator] Operator `+` is not supported between objects of type `YearBegin | MonthBegin | Minute | timedelta64[timedelta | int | None] | timedelta` and `Period`
- pandas/tests/scalar/period/test_arithmetic.py:214:21: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | YearBegin | MonthBegin | ... omitted 3 union elements` and `Period`
+ pandas/tests/scalar/period/test_arithmetic.py:214:21: error[unsupported-operator] Operator `+` is not supported between objects of type `YearBegin | MonthBegin | Minute | timedelta64[timedelta | int | None] | timedelta` and `Period`
- pandas/tests/scalar/period/test_arithmetic.py:261:21: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | YearBegin | MonthBegin | ... omitted 3 union elements` and `Period`
+ pandas/tests/scalar/period/test_arithmetic.py:261:21: error[unsupported-operator] Operator `+` is not supported between objects of type `YearBegin | MonthBegin | Minute | timedelta64[timedelta | int | None] | timedelta` and `Period`
- pandas/tests/scalar/period/test_period.py:1117:20: warning[possibly-missing-attribute] Attribute `dayofyear` may be missing on object of type `Unknown | Period`
+ pandas/tests/scalar/period/test_period.py:1117:20: error[unresolved-attribute] Object of type `Period` has no attribute `dayofyear`
- pandas/tests/scalar/timedelta/test_arithmetic.py:218:17: error[unsupported-operator] Operator `+` is not supported between objects of type `Timedelta` and `Unknown | int | float | signedinteger[_64Bit]`
+ pandas/tests/scalar/timedelta/test_arithmetic.py:218:17: error[unsupported-operator] Operator `+` is not supported between objects of type `Timedelta` and `Literal[2] | float | signedinteger[_64Bit]`
- pandas/tests/scalar/timedelta/test_arithmetic.py:220:17: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | int | float | signedinteger[_64Bit]` and `Timedelta`
+ pandas/tests/scalar/timedelta/test_arithmetic.py:220:17: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal[2] | float | signedinteger[_64Bit]` and `Timedelta`
- pandas/tests/scalar/timedelta/test_arithmetic.py:222:17: error[unsupported-operator] Operator `-` is not supported between objects of type `Timedelta` and `Unknown | int | float | signedinteger[_64Bit]`
+ pandas/tests/scalar/timedelta/test_arithmetic.py:222:17: error[unsupported-operator] Operator `-` is not supported between objects of type `Timedelta` and `Literal[2] | float | signedinteger[_64Bit]`
- pandas/tests/scalar/timedelta/test_arithmetic.py:224:17: error[unsupported-operator] Operator `-` is not supported between objects of type `Unknown | int | float | signedinteger[_64Bit]` and `Timedelta`
+ pandas/tests/scalar/timedelta/test_arithmetic.py:224:17: error[unsupported-operator] Operator `-` is not supported between objects of type `Literal[2] | float | signedinteger[_64Bit]` and `Timedelta`
- pandas/tests/scalar/timedelta/test_arithmetic.py:1000:43: error[invalid-argument-type] Argument to bound method `as_unit` is incorrect: Expected `Literal["s", "ms", "us", "ns"]`, found `Unknown | str`
- pandas/tests/scalar/timedelta/test_arithmetic.py:1001:43: error[invalid-argument-type] Argument to bound method `as_unit` is incorrect: Expected `Literal["s", "ms", "us", "ns"]`, found `Unknown | str`
- pandas/tests/scalar/timedelta/test_arithmetic.py:1019:43: error[invalid-argument-type] Argument to bound method `as_unit` is incorrect: Expected `Literal["s", "ms", "us", "ns"]`, found `Unknown | str`
- pandas/tests/scalar/timedelta/test_arithmetic.py:1020:43: error[invalid-argument-type] Argument to bound method `as_unit` is incorrect: Expected `Literal["s", "ms", "us", "ns"]`, found `Unknown | str`
- pandas/tests/scalar/timedelta/test_constructors.py:44:18: error[no-matching-overload] No overload of function `to_timedelta` matches arguments
- pandas/tests/scalar/timedelta/test_constructors.py:52:18: error[no-matching-overload] No overload of function `to_timedelta` matches arguments
- pandas/tests/scalar/timestamp/test_constructors.py:867:24: error[no-matching-overload] No overload of function `__new__` matches arguments
- pandas/tests/scalar/timestamp/test_timestamp.py:207:36: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `tzinfo | None`, found `Unknown | int`
- pandas/tests/series/methods/test_fillna.py:812:31: error[invalid-argument-type] Argument to bound method `fillna` is incorrect: Expected `int | None`, found `Unknown | int | float`
+ pandas/tests/series/methods/test_fillna.py:812:31: error[invalid-argument-type] Argument to bound method `fillna` is incorrect: Expected `int | None`, found `Literal[-1, 0] | float`
- pandas/tests/strings/test_split_partition.py:280:9: error[invalid-argument-type] Argument to bound method `from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `list[tuple[str, str, str] | list[Unknown | int | float] | list[Unknown | None]]`
+ pandas/tests/strings/test_split_partition.py:280:9: error[invalid-argument-type] Argument to bound method `from_tuples` is incorrect: Expected `Iterable[tuple[Hashable, ...]]`, found `list[tuple[Literal["some"], Literal["equal"], Literal["splits"]] | tuple[Literal["with"], Literal["no"], Literal["nans"]] | list[Unknown | int | float] | list[Unknown | None]]`
- pandas/tests/test_nanops.py:1153:37: error[invalid-argument-type] Argument to function `nanmean` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `Unknown | DatetimeIndex | DatetimeArray`
+ pandas/tests/test_nanops.py:1153:37: error[invalid-argument-type] Argument to function `nanmean` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `DatetimeIndex | DatetimeArray`
- pandas/tests/tools/test_to_datetime.py:2035:23: error[no-matching-overload] No overload of function `to_datetime` matches arguments
- Found 4437 diagnostics
+ Found 4427 diagnostics

ibis (https://github.com/ibis-project/ibis)
+ ibis/common/graph.py:475:34: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Self@find_topmost]`, found `tuple[Node, ...]`
- ibis/common/tests/test_grounds.py:643:16: warning[possibly-missing-attribute] Attribute `a` may be missing on object of type `Unknown | Annotable`
- ibis/common/tests/test_grounds.py:644:16: warning[possibly-missing-attribute] Attribute `b` may be missing on object of type `Unknown | Annotable`
- ibis/common/tests/test_grounds.py:645:16: warning[possibly-missing-attribute] Attribute `args` may be missing on object of type `Unknown | Annotable`
+ ibis/common/tests/test_grounds.py:643:16: error[unresolved-attribute] Object of type `Annotable` has no attribute `a`
+ ibis/common/tests/test_grounds.py:644:16: error[unresolved-attribute] Object of type `Annotable` has no attribute `b`
+ ibis/common/tests/test_grounds.py:645:16: error[unresolved-attribute] Object of type `Annotable` has no attribute `args`
- Found 4827 diagnostics
+ Found 4828 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:134:16: warning[possibly-missing-attribute] Attribute `is_commutative` may be missing on object of type `Unknown | Expr | int | float | complex`
+ sympy/algebras/quaternion.py:134:16: warning[possibly-missing-attribute] Attribute `is_commutative` may be missing on object of type `Expr | int | float | complex`
- sympy/algebras/tests/test_quaternion.py:422:33: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
+ sympy/codegen/tests/test_numpy_nodes.py:65:16: error[unresolved-attribute] Object of type `amin | amax` has no attribute `array`
+ sympy/codegen/tests/test_numpy_nodes.py:66:16: error[unresolved-attribute] Object of type `amin | amax` has no attribute `axis`
+ sympy/codegen/tests/test_numpy_nodes.py:67:16: error[unresolved-attribute] Object of type `amin | amax` has no attribute `axis`
- sympy/codegen/tests/test_matrix_nodes.py:27:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/codegen/tests/test_numpy_nodes.py:65:16: warning[possibly-missing-attribute] Attribute `array` may be missing on object of type `Unknown | amin | amax`
- sympy/codegen/tests/test_numpy_nodes.py:66:16: warning[possibly-missing-attribute] Attribute `axis` may be missing on object of type `Unknown | amin | amax`
- sympy/codegen/tests/test_numpy_nodes.py:67:16: warning[possibly-missing-attribute] Attribute `axis` may be missing on object of type `Unknown | amin | amax`
- sympy/core/tests/test_evalf.py:395:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `bool`, found `Unknown | int`
+ sympy/core/tests/test_evalf.py:395:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `bool`, found `Literal[0, False]`
- sympy/core/tests/test_evalf.py:396:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `bool`, found `Unknown | int`
+ sympy/core/tests/test_evalf.py:396:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `bool`, found `Literal[0, False]`
- sympy/core/tests/test_exprtools.py:289:29: error[invalid-argument-type] Argument to function `factor_terms` is incorrect: Expected `Expr | int | float | complex`, found `Unknown | list[Unknown] | tuple[Unknown, ...] | set[Unknown]`
+ sympy/core/tests/test_exprtools.py:289:29: error[invalid-argument-type] Argument to function `factor_terms` is incorrect: Expected `Expr | int | float | complex`, found `list[Unknown] | tuple[Unknown, ...] | set[Unknown]`
- sympy/core/tests/test_relational.py:406:35: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal[0]` and `Unknown | Equality | Unequality | ... omitted 4 union elements`
+ sympy/core/tests/test_relational.py:406:35: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal[0]` and `Equality | Unequality | LessThan | ... omitted 3 union elements`
- sympy/core/tests/test_relational.py:407:35: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[1]` and `Unknown | Equality | Unequality | ... omitted 4 union elements`
+ sympy/core/tests/test_relational.py:407:35: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[1]` and `Equality | Unequality | LessThan | ... omitted 3 union elements`
- sympy/core/tests/test_relational.py:408:35: error[unsupported-operator] Operator `**` is not supported between objects of type `Literal[1]` and `Unknown | Equality | Unequality | ... omitted 4 union elements`
+ sympy/core/tests/test_relational.py:408:35: error[unsupported-operator] Operator `**` is not supported between objects of type `Literal[1]` and `Equality | Unequality | LessThan | ... omitted 3 union elements`
- sympy/core/tests/test_relational.py:409:35: error[unsupported-operator] Operator `**` is not supported between objects of type `Unknown | Equality | Unequality | ... omitted 4 union elements` and `Literal[1]`
+ sympy/core/tests/test_relational.py:409:35: error[unsupported-operator] Operator `**` is not supported between objects of type `Equality | Unequality | LessThan | ... omitted 3 union elements` and `Literal[1]`
- sympy/core/tests/test_relational.py:410:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Expr | int | float | complex`, found `Unknown | Equality | Unequality | ... omitted 4 union elements`
+ sympy/core/tests/test_relational.py:410:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Expr | int | float | complex`, found `Equality | Unequality | LessThan | ... omitted 3 union elements`
- sympy/core/tests/test_relational.py:411:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Expr | int | float | complex`, found `Unknown | Equality | Unequality | ... omitted 4 union elements`
+ sympy/core/tests/test_relational.py:411:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Expr | int | float | complex`, found `Equality | Unequality | LessThan | ... omitted 3 union elements`
- sympy/core/tests/test_subs.py:558:12: error[no-matching-overload] No overload of bound method `subs` matches arguments
- sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:968:29: warning[possibly-missing-attribute] Attribute `is_nonnegative` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:968:47: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:969:12: warning[possibly-missing-attribute] Attribute `is_zero` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:975:12: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:976:16: warning[possibly-missing-attribute] Attribute `is_negative` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:978:18: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:984:14: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported

... (truncated 413 lines) ...

@AlexWaygood
Copy link
Member

AlexWaygood commented Feb 9, 2026

I think the ecosystem diff looks good overall, but it's a bit hard to tell because of the number of flakes. If you rebase on top of dc842db, you should get a cleaner ecosystem report that's easier to review. Here's a few interesting added diagnostics I spotted for now:

openlibrary/openlibrary/plugins/worksearch/schemes/works.py

[error] unsupported-operator - :288:18 - Operator & is not supported between objects of type Unknown | frozenset[Literal["title", "publisher", "oclc", "lccn", "contributor", ... omitted 7 literals]] and set[str]

This one is a false positive, but I think it's due to an overly restrictive type annotation in typeshed for frozenset.__and__. Typeshed says that frozenset.__and__ accepts AbstractSet[_T_co], but I think it should be AbstractSet[object], the same as set.__and__. Interestingly there are some similar diagnostics on pandas too.

optuna/optuna/study/_tell.py

[error] invalid-return-type - :176:12 - Return type does not match returned value: expected tuple[TrialState, list[int | float] | None, str | None], found tuple[TrialState, None | list[float], None | str]

This one is also a false positive, but I think it could be fixed in the future with the more advanced bidirectional inference we have planned. It's basically the same issue that we'll have with something like this, as soon as we get rid of our | Unknown unioning for generic parameters:

def f() -> list[int | None]:
    x = [1, 2, 3]
    return x

trio/src/trio/_core/_tests/test_tutil.py

[error] invalid-argument-type - :10:42 - Argument to function check_sequence_matches is incorrect: Expected Iterable[Literal[1, 2, 3, 4] | set[Literal[1, 2, 3, 4]]], found list[Literal[1, 4] | set[Unknown | int]]

This one seems a bit problematic. Do we need to recurse into nested collection literals when deciding that that element-types inside those literals shouldn't be promoted?

@ibraheemdev ibraheemdev force-pushed the ibraheem/covariant-literal-promotion branch from 46aac79 to 43d50fa Compare February 10, 2026 01:45
@ibraheemdev
Copy link
Member Author

ibraheemdev commented Feb 10, 2026

This one seems a bit problematic. Do we need to recurse into nested collection literals when deciding that that element-types inside those literals shouldn't be promoted?

Hmm, I'm not sure recursive promotion makes sense there, because the inner set elements are not actually in covariant position, and the set itself is still an invariant collection accessible through the list. I think this is a known limitation of the constraint solver not being able to solve unions of typevars:

from typing import Sequence, Iterable, Literal

def check_sequence_matches[T](seq: Sequence[T], template: Iterable[T | set[T]]):
    ...

def _(x: list[Literal[1]], y: list[Literal[1] | set[int]]):
    check_sequence_matches(x, y) # error: Expected `Iterable[Literal[1] | set[Literal[1]]]`, found `list[Literal[1] | set[int]]`

For reference, pyright does not error here.

@ibraheemdev ibraheemdev force-pushed the ibraheem/covariant-literal-promotion branch from 43d50fa to 3bf92a5 Compare February 10, 2026 04:38
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 10, 2026

Memory usage report

Summary

Project Old New Diff Outcome
sphinx 282.10MB 288.17MB +2.2% (6.07MB)
prefect 709.25MB 712.93MB +0.5% (3.68MB)
trio 123.73MB 124.30MB +0.5% (0.56MB)
flake8 51.80MB 51.87MB +0.1% (0.07MB)

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
ExpressionWithContext 0.02MB 0.02MB +51.6% (0.01MB)
Specialization 0.17MB 0.17MB +1.8% (0.00MB)
Type < 'db >::class_member_with_policy_::interned_arguments 0.31MB 0.32MB +0.6% (0.00MB)
Type < 'db >::apply_specialization_::interned_arguments 0.21MB 0.21MB +0.9% (0.00MB)
StaticClassLiteral < 'db >::try_mro_::interned_arguments 0.08MB 0.08MB +2.1% (0.00MB)
GenericAlias 0.08MB 0.08MB +2.1% (0.00MB)
FunctionType 0.45MB 0.45MB +0.3% (0.00MB)
UnionType 0.11MB 0.11MB +0.9% (0.00MB)
IntersectionType 0.08MB 0.08MB -0.7% (-0.00MB)
Type < 'db >::try_call_dunder_get_::interned_arguments 0.09MB 0.09MB +0.6% (0.00MB)
Type < 'db >::member_lookup_with_policy_::interned_arguments 0.21MB 0.22MB +0.2% (0.00MB)
CallableType 0.21MB 0.21MB +0.2% (0.00MB)
is_redundant_with_impl::interned_arguments 0.16MB 0.16MB -0.3% (-0.00MB)
BoundMethodType 0.05MB 0.05MB +0.7% (0.00MB)
code_generator_of_static_class::interned_arguments 0.03MB 0.03MB +1.2% (0.00MB)
... 19 more

prefect

Name Old New Diff Outcome
ExpressionWithContext 0.29MB 0.67MB +127.3% (0.38MB)
FunctionType 8.75MB 8.85MB +1.2% (0.11MB)
Specialization 2.55MB 2.65MB +3.7% (0.10MB)
CallableType 2.41MB 2.48MB +3.0% (0.07MB)
Type < 'db >::class_member_with_policy_::interned_arguments 9.33MB 9.40MB +0.7% (0.06MB)
Type < 'db >::apply_specialization_::interned_arguments 2.95MB 3.01MB +2.0% (0.06MB)
GenericAlias 1.20MB 1.26MB +4.5% (0.05MB)
StaticClassLiteral < 'db >::try_mro_::interned_arguments 1.44MB 1.49MB +3.7% (0.05MB)
UnionType 4.02MB 4.05MB +0.7% (0.03MB)
is_redundant_with_impl::interned_arguments 6.47MB 6.49MB +0.4% (0.03MB)
ProtocolInterface 0.36MB 0.38MB +5.1% (0.02MB)
Type < 'db >::try_call_dunder_get_::interned_arguments 3.09MB 3.10MB +0.5% (0.02MB)
IntersectionType 2.73MB 2.74MB +0.5% (0.01MB)
BoundMethodType 1.40MB 1.41MB +0.8% (0.01MB)
Type < 'db >::member_lookup_with_policy_::interned_arguments 5.56MB 5.57MB +0.2% (0.01MB)
... 31 more

sphinx

Name Old New Diff Outcome
UnionType 1.65MB 5.91MB +258.1% (4.26MB)
ExpressionWithContext 0.18MB 0.33MB +80.6% (0.15MB)
Specialization 1.09MB 1.15MB +5.9% (0.06MB)
FunctionType 3.32MB 3.38MB +1.9% (0.06MB)
CallableType 1.26MB 1.30MB +3.5% (0.04MB)
Type < 'db >::apply_specialization_::interned_arguments 1.54MB 1.58MB +2.8% (0.04MB)
is_redundant_with_impl::interned_arguments 2.77MB 2.81MB +1.3% (0.04MB)
GenericAlias 0.47MB 0.51MB +7.7% (0.04MB)
Type < 'db >::class_member_with_policy_::interned_arguments 4.23MB 4.26MB +0.8% (0.03MB)
StaticClassLiteral < 'db >::try_mro_::interned_arguments 0.50MB 0.53MB +6.5% (0.03MB)
ProtocolInterface 0.16MB 0.17MB +6.7% (0.01MB)
IntersectionType 1.08MB 1.09MB +0.9% (0.01MB)
Type < 'db >::try_call_dunder_get_::interned_arguments 1.30MB 1.30MB +0.7% (0.01MB)
BoundMethodType 0.74MB 0.74MB +1.0% (0.01MB)
code_generator_of_static_class::interned_arguments 0.26MB 0.26MB +2.4% (0.01MB)
... 25 more

trio

Name Old New Diff Outcome
UnionType 0.35MB 0.50MB +41.6% (0.15MB)
ExpressionWithContext 0.04MB 0.07MB +78.2% (0.03MB)
Specialization 0.49MB 0.52MB +5.1% (0.03MB)
FunctionType 1.62MB 1.63MB +1.1% (0.02MB)
GenericAlias 0.21MB 0.23MB +7.3% (0.02MB)
StaticClassLiteral < 'db >::try_mro_::interned_arguments 0.21MB 0.22MB +7.2% (0.02MB)
CallableType 0.72MB 0.73MB +1.9% (0.01MB)
Type < 'db >::class_member_with_policy_::interned_arguments 1.17MB 1.18MB +0.9% (0.01MB)
Type < 'db >::apply_specialization_::interned_arguments 0.68MB 0.69MB +1.4% (0.01MB)
is_redundant_with_impl::interned_arguments 0.59MB 0.60MB +1.5% (0.01MB)
IntersectionType 0.26MB 0.27MB +1.3% (0.00MB)
ProtocolInterface 0.11MB 0.11MB +2.9% (0.00MB)
code_generator_of_static_class::interned_arguments 0.10MB 0.10MB +2.4% (0.00MB)
Type < 'db >::try_call_dunder_get_::interned_arguments 0.37MB 0.38MB +0.6% (0.00MB)
Type < 'db >::member_lookup_with_policy_::interned_arguments 0.88MB 0.88MB +0.2% (0.00MB)
... 21 more

@carljm
Copy link
Contributor

carljm commented Feb 13, 2026

It seems like this might not be entirely desirable until we do #136? It will cause an example like this to error:

from typing import Iterable

x: Iterable[int] = [1, 2]
reveal_type(x)
x.append(4)  # bad argument, expected `Literal[1, 2]`

Of course that example will also error after #136, but for a more intuitive reason.

But with #136, you have the option to opt-out of the upcast by separating declaration from assignment:

from typing import Iterable

x: Iterable[int]
x = [1, 2]
reveal_type(x)
x.append(4)

It seems like with this PR, that will continue to error, which doesn't seem desirable -- I think we'd want literal promotion there.

It's not clear to me that the declared type being covariant is the right heuristic here, since an inferred type can always be a subtype of the declared type, so the inferred type being invariant can still cause problems with overly-precise inference.

@carljm carljm self-assigned this Feb 14, 2026
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.

Requesting changes to move this out of my review queue pending discussion of my comment above.

@ibraheemdev
Copy link
Member Author

I didn't realize that your second example would prefer the inferred type there. Maybe we need a more precise heuristic here based on the "source" of the type context? e.g., Iterable[T] from a function parameter annotation should probably avoid promotion, and so should a direct annotated assignment (after astral-sh/ty#136), but maybe not an unannotated assignment to a previously declared type? It does seem like we want less preference of the declared type in the latter case, given that we are actually preferring the inferred type.

@carljm
Copy link
Contributor

carljm commented Feb 18, 2026

Basically we want this logic only where the inferred type is effectively going to disappear in favor of the declared type. That's true for a function argument/parameter, and it's true for a direct annotated assignment (after #136).

But if that's the desired behavior, then do we need this at all? Or do we just need #136? If the inferred type isn't going to be used, does it matter how we infer it (as long as we correctly infer assignability to the declared type).

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Feb 18, 2026

I think it still matters for generic inference, e.g., if the parameter type is Iterable[T], and the inferred type is list[Literal[1]]. We currently promote the inferred type before inferring type variables, which leads to us inferring T = int instead of T = Literal[1].

The loop and for comprehension case is also interesting, because there isn't really a declared type there, it's more akin to generic inference against an Iterable[T].

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.

Avoid literal promotion for throwaway (non-escaping) invariant containers Avoid literal promotion when constructing frozenset from list/set literal

3 participants