Skip to content

Conversation

@ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Nov 13, 2025

Summary

Extends literal promotion to apply to any generic method, as opposed to only generic class constructors. This PR also improves our literal promotion heuristics to only promote literals in non-covariant position in the return type, and avoid promotion if the literal is present in non-covariant position in any argument type.

Resolves astral-sh/ty#1357.

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

astral-sh-bot bot commented Nov 13, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-promotion branch 2 times, most recently from 74a032c to 377f09c Compare November 13, 2025 21:56
@carljm
Copy link
Contributor

carljm commented Nov 14, 2025

It looks like this is causing a new stack overflow in the ecosystem?

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.

Reviewed the tests so far -- the behavior looks great! Thanks for the thorough and clear test suite.

Will review the code later.

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-promotion branch from 268ce0a to aef6378 Compare November 14, 2025 01:25
@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 14, 2025

mypy_primer results

Changes were detected when running on open source projects
nox (https://github.com/wntrblm/nox)
- nox/_resolver.py:167:13: error[invalid-assignment] Invalid subscript assignment with key of type `Node@lazy_stable_topo_sort` and value of type `Literal[True]` on object of type `dict[Node@lazy_stable_topo_sort, Literal[False]]`
- Found 30 diagnostics
+ Found 29 diagnostics

Expression (https://github.com/cognitedata/Expression)
- tests/test_map.py:142:34: error[invalid-argument-type] Argument to bound method `try_get_value` is incorrect: Expected `list[Literal[1, 2]]`, found `list[int]`
- tests/test_map.py:143:34: error[invalid-argument-type] Argument to bound method `try_get_value` is incorrect: Expected `list[Literal[1, 2]]`, found `list[int]`
- tests/test_map.py:144:34: error[invalid-argument-type] Argument to bound method `try_get_value` is incorrect: Expected `list[Literal[1, 2]]`, found `list[int]`
- Found 198 diagnostics
+ Found 195 diagnostics

psycopg (https://github.com/psycopg/psycopg)
- psycopg/psycopg/_adapters_map.py:147:21: error[invalid-assignment] Invalid subscript assignment with key of type `PyFormat` and value of type `Literal[True]` on object of type `dict[Unknown, Literal[False]]`
- tests/types/test_array.py:314:12: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- Found 635 diagnostics
+ Found 633 diagnostics

xarray (https://github.com/pydata/xarray)
- xarray/computation/rolling.py:112:45: error[invalid-argument-type] Argument to bound method `_mapping_to_list` is incorrect: Expected `Literal[False] | Mapping[Any, Literal[False]]`, found `bool | Mapping[Any, bool]`
- xarray/computation/rolling.py:453:41: error[invalid-argument-type] Argument to bound method `_mapping_to_list` is incorrect: Expected `Literal[1] | Mapping[Any, Literal[1]]`, found `int | Mapping[Any, int]`
- xarray/computation/rolling.py:989:41: error[invalid-argument-type] Argument to bound method `_mapping_to_list` is incorrect: Expected `Literal[1] | Mapping[Any, Literal[1]]`, found `int | Mapping[Any, int]`
- Found 1768 diagnostics
+ Found 1765 diagnostics

meson (https://github.com/mesonbuild/meson)
- mesonbuild/build.py:1295:9: error[invalid-assignment] Object of type `list[Sequence[str | Literal[False]] | Literal[False]]` is not assignable to attribute `install_dir` of type `list[str | Literal[False]]`
+ mesonbuild/build.py:1295:9: error[invalid-assignment] Object of type `list[Sequence[str | bool] | Literal[False]]` is not assignable to attribute `install_dir` of type `list[str | Literal[False]]`

manticore (https://github.com/trailofbits/manticore)
- manticore/core/manticore.py:1078:9: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `value` on type `Unknown | c_bool | ValueProxy[Literal[False]]`
- manticore/core/manticore.py:1156:9: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `value` on type `Unknown | c_bool | ValueProxy[Literal[False]]`
- Found 11087 diagnostics
+ Found 11085 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/appsec/_exploit_prevention/stack_traces.py:50:44: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[Literal[2]]`, in comparing `int` with `(Unknown & ~AlwaysFalsy) | (EnvVariable[Literal[2]] & ~AlwaysFalsy)`
+ ddtrace/appsec/_exploit_prevention/stack_traces.py:50:44: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `(Unknown & ~AlwaysFalsy) | (EnvVariable[int] & ~AlwaysFalsy)`
- ddtrace/appsec/_exploit_prevention/stack_traces.py:65:8: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[Literal[32]]`, in comparing `int` with `Unknown | EnvVariable[Literal[32]]`
+ ddtrace/appsec/_exploit_prevention/stack_traces.py:65:8: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/appsec/_exploit_prevention/stack_traces.py:65:21: error[unsupported-operator] Operator `>` is not supported for types `EnvVariable[Literal[32]]` and `int`, in comparing `Unknown | EnvVariable[Literal[32]]` with `Literal[0]`
+ ddtrace/appsec/_exploit_prevention/stack_traces.py:65:21: error[unsupported-operator] Operator `>` is not supported for types `EnvVariable[int]` and `int`, in comparing `Unknown | EnvVariable[int]` with `Literal[0]`
- ddtrace/appsec/_exploit_prevention/stack_traces.py:66:25: error[unsupported-operator] Operator `*` is unsupported between objects of type `Unknown | EnvVariable[Literal[32]]` and `Unknown | EnvVariable[float]`
+ ddtrace/appsec/_exploit_prevention/stack_traces.py:66:25: error[unsupported-operator] Operator `*` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Unknown | EnvVariable[float]`
- ddtrace/appsec/_exploit_prevention/stack_traces.py:67:24: error[unsupported-operator] Operator `-` is unsupported between objects of type `Unknown | EnvVariable[Literal[32]]` and `int`
+ ddtrace/appsec/_exploit_prevention/stack_traces.py:67:24: error[unsupported-operator] Operator `-` is unsupported between objects of type `Unknown | EnvVariable[int]` and `int`
- ddtrace/appsec/_iast/_metrics.py:25:23: warning[possibly-missing-attribute] Attribute `upper` may be missing on object of type `Unknown | EnvVariable[Literal["INFORMATION"]]`
+ ddtrace/appsec/_iast/_metrics.py:25:23: warning[possibly-missing-attribute] Attribute `upper` may be missing on object of type `Unknown | EnvVariable[str]`
- ddtrace/appsec/_iast/sampling/vulnerability_detection.py:40:8: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[Literal[2]]`, in comparing `int` with `Unknown | EnvVariable[Literal[2]]`
+ ddtrace/appsec/_iast/sampling/vulnerability_detection.py:40:8: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/appsec/_iast/sampling/vulnerability_detection.py:88:8: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[Literal[2]]`, in comparing `Unknown | int` with `Unknown | EnvVariable[Literal[2]]`
+ ddtrace/appsec/_iast/sampling/vulnerability_detection.py:88:8: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[int]`, in comparing `Unknown | int` with `Unknown | EnvVariable[int]`
- ddtrace/appsec/_iast/secure_marks/configuration.py:199:51: error[invalid-argument-type] Argument to function `parse_security_controls_config` is incorrect: Expected `str`, found `(Unknown & ~AlwaysFalsy) | (EnvVariable[Literal[""]] & ~AlwaysFalsy)`
+ ddtrace/appsec/_iast/secure_marks/configuration.py:199:51: error[invalid-argument-type] Argument to function `parse_security_controls_config` is incorrect: Expected `str`, found `(Unknown & ~AlwaysFalsy) | (EnvVariable[str] & ~AlwaysFalsy)`
- ddtrace/appsec/_iast/taint_sinks/_base.py:69:20: error[unsupported-operator] Operator `<` is not supported for types `int` and `EnvVariable[Literal[2]]`, in comparing `int` with `Unknown | EnvVariable[Literal[2]]`
+ ddtrace/appsec/_iast/taint_sinks/_base.py:69:20: error[unsupported-operator] Operator `<` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/appsec/_processor.py:105:49: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `Unknown | EnvVariable[Unknown | Literal["(?i)pass|pw(?:or)?d|secret|(?:api|private|public|access)[_-]?key|token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization|jsessionid|phpsessid|asp\\.net[_-]sessionid|sid|jwt"]]`
- ddtrace/appsec/_processor.py:106:51: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `Unknown | EnvVariable[Unknown | Literal["(?i)(?:p(?:ass)?w(?:or)?d|pass(?:[_-]?phrase)?|secret(?:[_-]?key)?|(?:(?:api|private|public|access)[_-]?)key(?:[_-]?id)?|(?:(?:auth|access|id|refresh)[_-]?)?token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?|jsessionid|phpsessid|asp\\.net(?:[_-]|-)sessionid|sid|jwt)(?:\\s*=([^;&]+)|\"\\s*:\\s*(\"[^\"]+\"|\\d+))|bearer\\s+([a-z0-9\\._\\-]+)|token\\s*:\\s*([a-z0-9]{13})|gh[opsu]_([0-9a-zA-Z]{36})|ey[I-L][\\w=-]+\\.(ey[I-L][\\w=-]+(?:\\.[\\w.+\\/=-]+)?)|[\\-]{5}BEGIN[a-z\\s]+PRIVATE\\sKEY[\\-]{5}([^\\-]+)[\\-]{5}END[a-z\\s]+PRIVATE\\sKEY|ssh-rsa\\s*([a-z0-9\\/\\.+]{100,})"]]`
+ ddtrace/appsec/_processor.py:105:49: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `Unknown | EnvVariable[Unknown | str]`
+ ddtrace/appsec/_processor.py:106:51: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `Unknown | EnvVariable[Unknown | str]`
- ddtrace/appsec/ai_guard/_api_client.py:107:25: error[unsupported-operator] Operator `//` is unsupported between objects of type `Unknown | EnvVariable[Literal[10000]]` and `Literal[1000]`
+ ddtrace/appsec/ai_guard/_api_client.py:107:25: error[unsupported-operator] Operator `//` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Literal[1000]`
- ddtrace/appsec/ai_guard/_api_client.py:116:12: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[Literal[16]]`, in comparing `int` with `Unknown | EnvVariable[Literal[16]]`
+ ddtrace/appsec/ai_guard/_api_client.py:116:12: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/appsec/ai_guard/_api_client.py:120:29: error[unsupported-operator] Unary operator `-` is unsupported for type `Unknown | EnvVariable[Literal[16]]`
+ ddtrace/appsec/ai_guard/_api_client.py:120:29: error[unsupported-operator] Unary operator `-` is unsupported for type `Unknown | EnvVariable[int]`
- ddtrace/appsec/ai_guard/_api_client.py:128:16: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[Literal[524288]]`, in comparing `int` with `Unknown | EnvVariable[Literal[524288]]`
+ ddtrace/appsec/ai_guard/_api_client.py:128:16: error[unsupported-operator] Operator `>` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/contrib/internal/django/user.py:50:53: error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Unknown | (EnvVariable[Literal[""]] & ~AlwaysFalsy) | str`
+ ddtrace/contrib/internal/django/user.py:50:53: error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Unknown | (EnvVariable[str] & ~AlwaysFalsy) | str`
- ddtrace/debugging/_exception/replay.py:332:35: error[unsupported-operator] Operator `<` is not supported for types `int` and `EnvVariable[Literal[8]]`, in comparing `int` with `Unknown | EnvVariable[Literal[8]]`
+ ddtrace/debugging/_exception/replay.py:332:35: error[unsupported-operator] Operator `<` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/debugging/_exception/replay.py:343:33: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[Literal[8]]`, in comparing `int` with `Unknown | EnvVariable[Literal[8]]`
+ ddtrace/debugging/_exception/replay.py:343:33: error[unsupported-operator] Operator `>=` is not supported for types `int` and `EnvVariable[int]`, in comparing `int` with `Unknown | EnvVariable[int]`
- ddtrace/debugging/_probe/remoteconfig.py:302:13: error[unsupported-operator] Operator `+` is unsupported between objects of type `int | float` and `Unknown | EnvVariable[Literal[3600]]`
+ ddtrace/debugging/_probe/remoteconfig.py:302:13: error[unsupported-operator] Operator `+` is unsupported between objects of type `int | float` and `Unknown | EnvVariable[int]`
- ddtrace/internal/core/crashtracking.py:111:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | EnvVariable[Literal[True]]`
+ ddtrace/internal/core/crashtracking.py:111:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | EnvVariable[bool]`
- ddtrace/internal/core/crashtracking.py:112:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | EnvVariable[Literal[True]]`
+ ddtrace/internal/core/crashtracking.py:112:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | EnvVariable[bool]`
- ddtrace/internal/gitmetadata.py:52:35: error[invalid-argument-type] Argument to function `parse_tags_str` is incorrect: Expected `str | None`, found `Unknown | EnvVariable[Literal[""]]`
+ ddtrace/internal/gitmetadata.py:52:35: error[invalid-argument-type] Argument to function `parse_tags_str` is incorrect: Expected `str | None`, found `Unknown | EnvVariable[str]`
- ddtrace/internal/openfeature/writer.py:99:13: error[invalid-assignment] Object of type `Unknown | EnvVariable[Literal[True]]` is not assignable to `bool | None`
+ ddtrace/internal/openfeature/writer.py:99:13: error[invalid-assignment] Object of type `Unknown | EnvVariable[bool]` is not assignable to `bool | None`
- ddtrace/internal/settings/_opentelemetry.py:10:61: error[invalid-argument-type] Argument to function `_get_default_endpoint` is incorrect: Expected `str`, found `Unknown | EnvVariable[Literal["grpc"]]`
+ ddtrace/internal/settings/_opentelemetry.py:10:61: error[invalid-argument-type] Argument to function `_get_default_endpoint` is incorrect: Expected `str`, found `Unknown | EnvVariable[str]`
- ddtrace/internal/settings/asm.py:199:5: error[invalid-assignment] Object of type `EnvVariable[Literal[1]]` is not assignable to `int`
+ ddtrace/internal/settings/asm.py:199:5: error[invalid-assignment] Object of type `EnvVariable[int]` is not assignable to `int`
- ddtrace/internal/settings/asm.py:322:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Unknown | Literal[False] | (EnvVariable[Literal[False]] & ~AlwaysTruthy) | EnvVariable[Literal[True]]`
+ ddtrace/internal/settings/asm.py:322:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Unknown | Literal[False] | EnvVariable[bool]`
- ddtrace/internal/settings/asm.py:326:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `(Unknown & ~AlwaysFalsy & ~AlwaysTruthy) | (EnvVariable[Literal[False]] & ~AlwaysFalsy & ~AlwaysTruthy) | bool`
+ ddtrace/internal/settings/asm.py:326:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `(Unknown & ~AlwaysFalsy & ~AlwaysTruthy) | (EnvVariable[bool] & ~AlwaysFalsy & ~AlwaysTruthy) | bool`
- ddtrace/internal/settings/asm.py:335:20: error[invalid-return-type] Return type does not match returned value: expected `str`, found `Unknown | EnvVariable[Literal["identification"]] | Literal["disabled"]`
+ ddtrace/internal/settings/asm.py:335:20: error[invalid-return-type] Return type does not match returned value: expected `str`, found `Unknown | EnvVariable[str] | Literal["disabled"]`
- ddtrace/internal/settings/profiling.py:124:9: error[invalid-argument-type] Argument to bound method `v` is incorrect: Expected `((str, /) -> Literal[False]) | None`, found `def _parse_profiling_enabled(raw: str) -> bool`
- ddtrace/internal/telemetry/writer.py:68:45: error[invalid-argument-type] Argument to bound method `get_host` is incorrect: Expected `str`, found `Unknown | EnvVariable[Literal["datadoghq.com"]]`
+ ddtrace/internal/telemetry/writer.py:68:45: error[invalid-argument-type] Argument to bound method `get_host` is incorrect: Expected `str`, found `Unknown | EnvVariable[str]`
- ddtrace/internal/telemetry/writer.py:181:13: error[invalid-assignment] Object of type `(Unknown & ~AlwaysFalsy) | (EnvVariable[Literal[False]] & ~AlwaysFalsy) | bool` is not assignable to `bool | None`
+ ddtrace/internal/telemetry/writer.py:181:13: error[invalid-assignment] Object of type `(Unknown & ~AlwaysFalsy) | (EnvVariable[bool] & ~AlwaysFalsy) | bool` is not assignable to `bool | None`
- ddtrace/internal/telemetry/writer.py:350:46: error[invalid-argument-type] Argument to bound method `flush` is incorrect: Expected `int`, found `Unknown | EnvVariable[Unknown | Literal[300]]`
+ ddtrace/internal/telemetry/writer.py:350:46: error[invalid-argument-type] Argument to bound method `flush` is incorrect: Expected `int`, found `Unknown | EnvVariable[Unknown | int]`
- ddtrace/profiling/collector/_lock.py:268:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[Literal[64]]` is not assignable to annotated parameter type `int`
+ ddtrace/profiling/collector/_lock.py:268:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[int]` is not assignable to annotated parameter type `int`
- ddtrace/profiling/profiler.py:129:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[Literal[True]]` is not assignable to annotated parameter type `bool`
+ ddtrace/profiling/profiler.py:129:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[bool]` is not assignable to annotated parameter type `bool`
- ddtrace/profiling/profiler.py:130:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[Literal[True]]` is not assignable to annotated parameter type `bool`
+ ddtrace/profiling/profiler.py:130:9: error[invalid-parameter-default] Default value of type `Unknown | EnvVariable[bool]` is not assignable to annotated parameter type `bool`
- ddtrace/profiling/profiler.py:180:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[Literal[64]]`
+ ddtrace/profiling/profiler.py:180:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[int]`
- ddtrace/profiling/profiler.py:181:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `bool | None`, found `Unknown | EnvVariable[Literal[True]]`
+ ddtrace/profiling/profiler.py:181:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `bool | None`, found `Unknown | EnvVariable[bool]`
- ddtrace/profiling/profiler.py:183:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[Literal[4]]`
+ ddtrace/profiling/profiler.py:183:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[int]`
- ddtrace/profiling/profiler.py:184:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[Literal[10000]]`
+ ddtrace/profiling/profiler.py:184:13: error[invalid-argument-type] Argument to function `config` is incorrect: Expected `int | None`, found `Unknown | EnvVariable[int]`
- tests/appsec/ai_guard/api/test_api_client.py:195:20: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[Literal[16]]` and `Literal[1]`
+ tests/appsec/ai_guard/api/test_api_client.py:195:20: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Literal[1]`
- tests/appsec/ai_guard/api/test_api_client.py:210:35: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[Literal[524288]]` and `Literal[1]`
+ tests/appsec/ai_guard/api/test_api_client.py:210:35: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Literal[1]`
- tests/appsec/iast/test_overhead_control_engine.py:129:48: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[Literal[2]]` and `Literal[1]`
+ tests/appsec/iast/test_overhead_control_engine.py:129:48: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Literal[1]`
- tests/debugging/exception/test_replay.py:347:17: error[unsupported-operator] Operator `*` is unsupported between objects of type `Unknown | EnvVariable[Literal[8]]` and `Literal[2]`
+ tests/debugging/exception/test_replay.py:347:17: error[unsupported-operator] Operator `*` is unsupported between objects of type `Unknown | EnvVariable[int]` and `Literal[2]`
- Found 7974 diagnostics
+ Found 7973 diagnostics

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/bigquery/tests/unit/test_compiler.py:273:26: error[invalid-argument-type] Argument is incorrect: Expected `FrozenOrderedDict[str, DataType]`, found `dict[str | Unknown, Literal["string"]]`
+ ibis/backends/bigquery/tests/unit/test_compiler.py:273:26: error[invalid-argument-type] Argument is incorrect: Expected `FrozenOrderedDict[str, DataType]`, found `dict[str | Unknown, str]`
- ibis/backends/tests/test_udf.py:82:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, int]`, found `dict[Unknown, Literal[0]]`
- ibis/backends/tests/test_udf.py:110:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, int]`, found `dict[Unknown, Literal[0]]`
- ibis/backends/tests/test_udf.py:124:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, int]`, found `dict[Unknown, Literal[0]]`
- Found 4233 diagnostics
+ Found 4230 diagnostics

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
- tests/scalars/test_scalars.py:160:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/scalars/test_scalars.py:176:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/scalars/test_scalars.py:208:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/scalars/test_scalars.py:225:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/scalars/test_scalars.py:250:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/scalars/test_scalars.py:251:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:41:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:42:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:43:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:45:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:101:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- tests/test_interval.py:103:11: error[type-assertion-failure] Argument does not have asserted type `Interval[int]`
- Found 5966 diagnostics
+ Found 5954 diagnostics

zulip (https://github.com/zulip/zulip)
- zerver/tests/test_users.py:256:25: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["email"], Unknown].__getitem__(key: Literal["email"], /) -> Unknown` cannot be called with key of type `Literal["is_owner"]` on object of type `dict[Literal["email"], Unknown]`
- zerver/tests/test_users.py:258:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["email"], Unknown].__getitem__(key: Literal["email"], /) -> Unknown` cannot be called with key of type `Literal["is_owner"]` on object of type `dict[Literal["email"], Unknown]`
- zerver/tests/test_users.py:315:25: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["email"], Unknown].__getitem__(key: Literal["email"], /) -> Unknown` cannot be called with key of type `Literal["is_admin"]` on object of type `dict[Literal["email"], Unknown]`
- zerver/tests/test_users.py:317:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["email"], Unknown].__getitem__(key: Literal["email"], /) -> Unknown` cannot be called with key of type `Literal["is_admin"]` on object of type `dict[Literal["email"], Unknown]`
- zerver/tests/test_users.py:358:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["email"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:359:27: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["avatar_url"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:360:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["delivery_email"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:384:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["email"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:386:13: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["avatar_url"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:399:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["email"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:401:13: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["avatar_url"]` on object of type `dict[Literal["user_id"], Unknown]`
- zerver/tests/test_users.py:403:26: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["user_id"], Unknown].__getitem__(key: Literal["user_id"], /) -> Unknown` cannot be called with key of type `Literal["delivery_email"]` on object of type `dict[Literal["user_id"], Unknown]`
- zproject/backends.py:176:21: error[invalid-argument-type] Argument to function `pad_method_dict` is incorrect: Expected `dict[str, bool]`, found `dict[str, bool] | dict[str, Literal[True]]`
- Found 3282 diagnostics
+ Found 3269 diagnostics

rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/ethereum/modules/yearn/decoder.py:404:13: error[invalid-return-type] Return type does not match returned value: expected `dict[ChecksumAddress, str]`, found `dict[ChecksumAddress, Literal["yearn-v1", "yearn-v2"]]`
- rotkehlchen/db/dbhandler.py:2576:9: error[no-matching-overload] No overload of bound method `update` matches arguments
- Found 2134 diagnostics
+ Found 2132 diagnostics

core (https://github.com/home-assistant/core)
- homeassistant/components/ukraine_alarm/coordinator.py:57:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `Literal[True]` on object of type `dict[Unknown | str, Literal[False]]`
- Found 14474 diagnostics
+ Found 14473 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 14, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 0 20 13
unsupported-operator 0 0 19
type-assertion-failure 0 12 0
invalid-assignment 0 6 4
invalid-return-type 0 6 3
invalid-parameter-default 0 0 3
possibly-missing-attribute 0 0 3
no-matching-overload 0 1 0
non-subscriptable 0 1 0
Total 0 46 45

Full report with detailed diff (timing results)

@ibraheemdev ibraheemdev force-pushed the ibraheem/generic-promotion branch from aef6378 to 63ce623 Compare November 14, 2025 20:40
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.

This looks great!

@ibraheemdev ibraheemdev merged commit c5d654b into main Nov 14, 2025
40 checks passed
@ibraheemdev ibraheemdev deleted the ibraheem/generic-promotion branch November 14, 2025 21:13
dcreager added a commit that referenced this pull request Nov 14, 2025
* origin/main: (59 commits)
  [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461)
  [ty] Improve literal promotion heuristics (#21439)
  [ty] Further improve details around which expressions should be deferred in stub files (#21456)
  [ty] Improve generic class constructor inference (#21442)
  [ty] Propagate type context through conditional expressions (#21443)
  [ty] Suppress completions when introducing names with `as`
  [ty] Add panic-by-default await methods to `TestServer` (#21451)
  [ty] name is parameter and global is a syntax error (#21312)
  [ty] Fixup a few details around version-specific dataclass features (#21453)
  [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449)
  [ty] Support stringified annotations in value-position `Annotated` instances (#21447)
  [ty] Type inference for genererator expressions (#21437)
  [ty] Make `__getattr__` available for `ModuleType` instances (#21450)
  [ty] Increase default receive timeout in tests to 10s (#21448)
  [ty] Add synthetic members to completions on dataclasses (#21446)
  [ty] Support legacy `typing` special forms in implicit type aliases (#21433)
  Bump 0.14.5 (#21435)
  [ty] Support `type[…]` and `Type[…]` in implicit type aliases (#21421)
  [ty] Respect notebook cell boundaries when adding an auto import (#21322)
  Update PyCharm setup instructions (#21409)
  ...
dcreager added a commit that referenced this pull request Nov 14, 2025
* dcreager/deep-comparison: (64 commits)
  assuming
  SubtypingAssuming
  implies_subtype_of
  name tweak
  Apply suggestions from code review
  [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461)
  [ty] Improve literal promotion heuristics (#21439)
  [ty] Further improve details around which expressions should be deferred in stub files (#21456)
  [ty] Improve generic class constructor inference (#21442)
  [ty] Propagate type context through conditional expressions (#21443)
  [ty] Suppress completions when introducing names with `as`
  [ty] Add panic-by-default await methods to `TestServer` (#21451)
  [ty] name is parameter and global is a syntax error (#21312)
  [ty] Fixup a few details around version-specific dataclass features (#21453)
  [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449)
  [ty] Support stringified annotations in value-position `Annotated` instances (#21447)
  [ty] Type inference for genererator expressions (#21437)
  [ty] Make `__getattr__` available for `ModuleType` instances (#21450)
  [ty] Increase default receive timeout in tests to 10s (#21448)
  [ty] Add synthetic members to completions on dataclasses (#21446)
  ...
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.

Literal promotion is not performed for generic calls

3 participants