Skip to content

[ty] Infer lambda expressions with Callable type context#22633

Draft
ibraheemdev wants to merge 1 commit intomainfrom
ibraheem/lambda-tcx
Draft

[ty] Infer lambda expressions with Callable type context#22633
ibraheemdev wants to merge 1 commit intomainfrom
ibraheem/lambda-tcx

Conversation

@ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Jan 16, 2026

Infer lambda expressions eagerly as part of their parent scope, and with type context. This allows us to infer more precise types for lambda expressions, as well as perform check assignability against Callable annotations.

Note that this does not change the inferred type of a lambda parameter with the body of the lambda, even if it is annotated. That part is a little more tricky, so will be addressed in a followup PR.

This PR is stacked on #22564.

@ibraheemdev ibraheemdev added the ty Multi-file analysis & type inference label Jan 16, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 16, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 16, 2026

mypy_primer results

Changes were detected when running on open source projects
attrs (https://github.com/python-attrs/attrs)
+ tests/test_cmp.py:364:23: error[invalid-argument-type] Argument to function `cmp_using` is incorrect: Expected `((Any, Any, /) -> bool) | None`, found `(a: Any, b: Any) -> _NotImplementedType | (bool & Unknown)`
- tests/test_validators.py:228:32: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((str, str, int, /) -> Match[str] | None) | None`, found `() -> Unknown`
+ tests/test_validators.py:228:32: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((str, str, int, /) -> Match[str] | None) | None`, found `() -> None`
- tests/test_validators.py:448:52: error[invalid-argument-type] Argument to function `include` is incorrect: Expected `type | str | Attribute[Any]`, found `(val) -> Unknown`
+ tests/test_validators.py:448:52: error[invalid-argument-type] Argument to function `include` is incorrect: Expected `type | str | Attribute[Any]`, found `(val) -> Literal[True]`
- tests/test_validators.py:449:52: error[invalid-argument-type] Argument to function `exclude` is incorrect: Expected `type | str | Attribute[Any]`, found `(val) -> Unknown`
+ tests/test_validators.py:449:52: error[invalid-argument-type] Argument to function `exclude` is incorrect: Expected `type | str | Attribute[Any]`, found `(val) -> Literal[True]`
- Found 628 diagnostics
+ Found 629 diagnostics

anyio (https://github.com/agronholm/anyio)
+ src/anyio/_core/_tempfile.py:108:9: error[invalid-assignment] Object of type `AsyncFile[str]` is not assignable to attribute `_async_file` of type `AsyncFile[AnyStr@TemporaryFile]`
- Found 92 diagnostics
+ Found 93 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/spec.py:4025:60: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `defaultdict[Unknown, Unknown] | None`
+ lib/spack/spack/spec.py:4025:60: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `defaultdict[Unknown, int] | None`
- lib/spack/spack/test/llnl/util/lock.py:1102:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> bool) | None | ContextManager[Unknown]`, found `def write(t, v, tb) -> Unknown`
- lib/spack/spack/test/llnl/util/lock.py:1108:36: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> bool) | None | ContextManager[Unknown]`, found `def write(t, v, tb) -> Unknown`
- lib/spack/spack/test/llnl/util/lock.py:1112:44: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> bool) | None | ContextManager[Unknown]`, found `def write(t, v, tb) -> Unknown`
- lib/spack/spack/test/llnl/util/lock.py:1121:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> bool) | None | ContextManager[Unknown]`, found `def write(t, v, tb) -> Unknown`
- lib/spack/spack/test/llnl/util/lock.py:1125:48: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> bool) | None | ContextManager[Unknown]`, found `def write(t, v, tb) -> Unknown`
- lib/spack/spack/util/file_cache.py:159:76: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/util/file_cache.py:175:77: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 4336 diagnostics
+ Found 4329 diagnostics

asynq (https://github.com/quora/asynq)
- asynq/tests/test_futures.py:22:5: error[unresolved-attribute] Object of type `Future[Unknown]` has no attribute `on_computed`
+ asynq/tests/test_futures.py:22:5: error[unresolved-attribute] Object of type `Future[int]` has no attribute `on_computed`
- asynq/tests/test_futures.py:25:5: error[unresolved-attribute] Object of type `Future[Unknown]` has no attribute `on_computed`
+ asynq/tests/test_futures.py:25:5: error[unresolved-attribute] Object of type `Future[int]` has no attribute `on_computed`

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/_reloader.py:446:35: error[invalid-argument-type] Argument to function `signal` is incorrect: Expected `((int, FrameType | None, /) -> Any) | int | None`, found `(*args: int) -> Never`
- tests/live_apps/run.py:35:5: error[invalid-assignment] Object of type `(_) -> Unknown` is not assignable to attribute `address_string` of type `def address_string(self) -> str`
+ tests/live_apps/run.py:35:5: error[invalid-assignment] Object of type `(_) -> Any` is not assignable to attribute `address_string` of type `def address_string(self) -> str`
- Found 407 diagnostics
+ Found 408 diagnostics

aiortc (https://github.com/aiortc/aiortc)
+ src/aiortc/rtcdtlstransport.py:199:64: error[invalid-argument-type] Argument to bound method `set_verify` is incorrect: Expected `((Connection, X509, int, int, int, /) -> bool) | None`, found `(*args: Connection) -> Literal[True]`
- Found 194 diagnostics
+ Found 195 diagnostics

paasta (https://github.com/yelp/paasta)
+ paasta_tools/frameworks/constraints.py:25:37: error[invalid-assignment] Object of type `dict[str, ((str, str, str, dict[str, dict[str, Any]], /) -> bool) | ((cv: str, ov: str, *_: str) -> Unknown) | ((cv: str, ov: str, *_: str) -> bool)]` is not assignable to `dict[str, (str, str, str, dict[str, dict[str, Any]], /) -> bool]`
- Found 1104 diagnostics
+ Found 1105 diagnostics

pytest (https://github.com/pytest-dev/pytest)
+ testing/_py/test_local.py:918:35: error[invalid-argument-type] Argument to bound method `sysfind` is incorrect: Expected `((local, /) -> bool) | None`, found `(x: local) -> None`
- Found 399 diagnostics
+ Found 400 diagnostics

graphql-core (https://github.com/graphql-python/graphql-core)
+ tests/validation/test_validation.py:49:49: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((GraphQLSchema, GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, FieldNode, /) -> GraphQLField | None) | None`, found `(*_args: GraphQLSchema) -> None`
- Found 641 diagnostics
+ Found 642 diagnostics

ignite (https://github.com/pytorch/ignite)
- tests/ignite/engine/test_engine.py:60:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `() -> Unknown`
+ tests/ignite/engine/test_engine.py:60:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `() -> None`
- tests/ignite/engine/test_engine.py:63:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `(batch) -> Unknown`
+ tests/ignite/engine/test_engine.py:63:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `(batch: Engine) -> None`
- tests/ignite/engine/test_engine.py:66:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `(engine, batch, extra_arg) -> Unknown`
+ tests/ignite/engine/test_engine.py:66:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Engine, Any, /) -> Any`, found `(engine: Engine, batch: Any, extra_arg) -> None`
+ tests/ignite/handlers/test_checkpoint.py:102:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((Engine, /) -> int | float) | None`, found `(e: Engine) -> dict[Unknown | str, Unknown | int]`
- Found 2071 diagnostics
+ Found 2072 diagnostics

sockeye (https://github.com/awslabs/sockeye)
+ sockeye_contrib/plot_metrics.py:24:1: error[no-matching-overload] No overload of bound method `update` matches arguments
- Found 415 diagnostics
+ Found 416 diagnostics

httpx-caching (https://github.com/johtso/httpx-caching)
+ httpx_caching/_utils.py:47:19: error[invalid-await] `Unknown | None` is not awaitable
- Found 27 diagnostics
+ Found 28 diagnostics

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/adapter/parameters.py:998:48: error[invalid-argument-type] Argument to bound method `filter` is incorrect: Expected `(GeneratedValue, /) -> Any`, found `Unknown | ((parameters: dict[str, object]) -> bool) | ((headers: dict[str, object]) -> bool) | ((query: dict[str, object]) -> bool)`
+ src/schemathesis/specs/openapi/adapter/parameters.py:1010:45: error[invalid-argument-type] Argument to bound method `map` is incorrect: Expected `(GeneratedValue, /) -> Unknown`, found `def quote_all(parameters: dict[str, Any]) -> dict[str, Any]`
+ src/schemathesis/specs/openapi/adapter/parameters.py:1015:45: error[invalid-argument-type] Argument to bound method `map` is incorrect: Expected `(GeneratedValue, /) -> Unknown`, found `def jsonify_python_specific_types(value: dict[str, Any]) -> dict[str, Any]`
- Found 280 diagnostics
+ Found 283 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `bool`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> Unknown)`
+ tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `bool`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> str)`
- tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `str | ((str, /) -> str)`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> Unknown)`
+ tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `str | ((str, /) -> str)`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> str)`
- tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `bool`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> Unknown)`
+ tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `bool`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> str)`
- tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `list[str]`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> Unknown)`
+ tornado/test/escape_test.py:217:51: error[invalid-argument-type] Argument to function `linkify` is incorrect: Expected `list[str]`, found `Unknown | list[Unknown | str] | bool | str | ((href) -> str)`

urllib3 (https://github.com/urllib3/urllib3)
- test/contrib/emscripten/test_emscripten.py:387:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `is_cross_origin_isolated` of type `def is_cross_origin_isolated() -> bool`
+ test/contrib/emscripten/test_emscripten.py:387:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `is_cross_origin_isolated` of type `def is_cross_origin_isolated() -> bool`

optuna (https://github.com/optuna/optuna)
+ optuna/visualization/matplotlib/_contour.py:168:31: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Buffer]`, found `filter[Unknown | str | int | float | None]`
- tests/study_tests/test_optimize.py:73:82: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/study_tests/test_optimize.py:78:86: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/visualization_tests/test_utils.py:177:71: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 579 diagnostics
+ Found 577 diagnostics

vision (https://github.com/pytorch/vision)
+ references/depth/stereo/transforms.py:124:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, ...], tuple[Unknown | None, ...], tuple[Unknown | None, ...]]`
- Found 1403 diagnostics
+ Found 1404 diagnostics

Expression (https://github.com/cognitedata/Expression)
+ tests/test_result.py:315:46: error[invalid-argument-type] Argument to bound method `filter_with` is incorrect: Expected `(Any, /) -> Literal["original error"]`, found `(value: Any) -> str`
+ tests/test_result.py:517:26: error[invalid-argument-type] Argument to bound method `or_else_with` is incorrect: Expected `(Any, /) -> Result[Literal["good"], Any]`, found `(error: Any) -> Result[str, Any]`
+ tests/test_result.py:523:26: error[invalid-argument-type] Argument to bound method `or_else_with` is incorrect: Expected `(Any, /) -> Result[Literal["good"], Any]`, found `(error: Any) -> Result[str, Any]`
+ tests/test_result.py:535:26: error[invalid-argument-type] Argument to bound method `or_else_with` is incorrect: Expected `(Literal["original error"], /) -> Result[Any, Literal["original error"]]`, found `(error: Literal["original error"]) -> Result[Any, str]`
- Found 205 diagnostics
+ Found 209 diagnostics

mkdocs (https://github.com/mkdocs/mkdocs)
- mkdocs/tests/livereload_tests.py:21:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `close` of type `def close(self) -> None`
+ mkdocs/tests/livereload_tests.py:21:9: error[invalid-assignment] Object of type `() -> None` is not assignable to attribute `close` of type `def close(self) -> None`

operator (https://github.com/canonical/operator)
- ops/_private/harness.py:2075:74: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 132 diagnostics
+ Found 131 diagnostics

meson (https://github.com/mesonbuild/meson)
- docs/refman/main.py:42:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `colorize_console` of type `bound method _Logger.colorize_console() -> bool`
+ docs/refman/main.py:42:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `colorize_console` of type `bound method _Logger.colorize_console() -> bool`
- mesonbuild/dependencies/cuda.py:137:76: error[invalid-argument-type] Argument to function `version_compare_many` is incorrect: Expected `str`, found `Unknown | str | None`
- unittests/internaltests.py:245:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `get_default_include_dirs` of type `def get_default_include_dirs(self) -> list[str]`
+ unittests/internaltests.py:245:9: error[invalid-assignment] Object of type `() -> list[Unknown | str]` is not assignable to attribute `get_default_include_dirs` of type `def get_default_include_dirs(self) -> list[str]`
- unittests/internaltests.py:275:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `get_default_include_dirs` of type `def get_default_include_dirs(self) -> list[str]`
+ unittests/internaltests.py:275:9: error[invalid-assignment] Object of type `() -> list[Unknown | str]` is not assignable to attribute `get_default_include_dirs` of type `def get_default_include_dirs(self) -> list[str]`
+ unittests/machinefiletests.py:154:26: warning[possibly-missing-attribute] Attribute `id` may be missing on object of type `Compiler | None`

pyppeteer (https://github.com/pyppeteer/pyppeteer)
+ pyppeteer/browser.py:66:13: error[invalid-argument-type] Argument to bound method `setClosedCallback` is incorrect: Expected `() -> None`, found `() -> bool`
- Found 87 diagnostics
+ Found 88 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
- discord/enums.py:97:5: error[invalid-assignment] Object of type `(self) -> Unknown` is not assignable to attribute `__repr__` of type `def __repr__(self) -> str`
+ discord/enums.py:97:5: error[invalid-assignment] Object of type `(self) -> str` is not assignable to attribute `__repr__` of type `def __repr__(self) -> str`
- discord/enums.py:98:5: error[invalid-assignment] Object of type `(self) -> Unknown` is not assignable to attribute `__str__` of type `def __str__(self) -> str`
+ discord/enums.py:98:5: error[invalid-assignment] Object of type `(self) -> str` is not assignable to attribute `__str__` of type `def __str__(self) -> str`
- discord/enums.py:100:9: error[invalid-assignment] Object of type `(self, other) -> Unknown` is not assignable to attribute `__le__` of type `def __le__(self, value: tuple[Unknown, ...], /) -> bool`
+ discord/enums.py:100:9: error[invalid-assignment] Object of type `(self, other) -> Literal[False] | Unknown` is not assignable to attribute `__le__` of type `def __le__(self, value: tuple[Unknown, ...], /) -> bool`
- discord/enums.py:101:9: error[invalid-assignment] Object of type `(self, other) -> Unknown` is not assignable to attribute `__ge__` of type `def __ge__(self, value: tuple[Unknown, ...], /) -> bool`
+ discord/enums.py:101:9: error[invalid-assignment] Object of type `(self, other) -> Literal[False] | Unknown` is not assignable to attribute `__ge__` of type `def __ge__(self, value: tuple[Unknown, ...], /) -> bool`
- discord/enums.py:102:9: error[invalid-assignment] Object of type `(self, other) -> Unknown` is not assignable to attribute `__lt__` of type `def __lt__(self, value: tuple[Unknown, ...], /) -> bool`
+ discord/enums.py:102:9: error[invalid-assignment] Object of type `(self, other) -> Literal[False] | Unknown` is not assignable to attribute `__lt__` of type `def __lt__(self, value: tuple[Unknown, ...], /) -> bool`
- discord/enums.py:103:9: error[invalid-assignment] Object of type `(self, other) -> Unknown` is not assignable to attribute `__gt__` of type `def __gt__(self, value: tuple[Unknown, ...], /) -> bool`
+ discord/enums.py:103:9: error[invalid-assignment] Object of type `(self, other) -> Literal[False] | Unknown` is not assignable to attribute `__gt__` of type `def __gt__(self, value: tuple[Unknown, ...], /) -> bool`
- discord/file.py:106:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `close` of type `def close(self) -> None`
+ discord/file.py:106:9: error[invalid-assignment] Object of type `() -> None` is not assignable to attribute `close` of type `def close(self) -> None`

zope.interface (https://github.com/zopefoundation/zope.interface)
- src/zope/interface/registry.py:552:9: error[invalid-assignment] Object of type `(_) -> Unknown` is not assignable to attribute `changed` on type `Unknown | AdapterRegistry`
+ src/zope/interface/registry.py:552:9: error[invalid-assignment] Object of type `(_) -> None` is not assignable to attribute `changed` on type `Unknown | AdapterRegistry`

trio (https://github.com/python-trio/trio)
- src/trio/_core/_tests/test_run.py:88:34: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- src/trio/_core/_tests/test_run.py:1048:64: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- src/trio/_tests/test_util.py:139:53: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 487 diagnostics
+ Found 484 diagnostics

cloud-init (https://github.com/canonical/cloud-init)
- tests/unittests/sources/test_altcloud.py:157:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:157:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
- tests/unittests/sources/test_altcloud.py:169:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:169:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
- tests/unittests/sources/test_altcloud.py:181:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:181:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
- tests/unittests/sources/test_altcloud.py:190:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:190:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
- tests/unittests/sources/test_altcloud.py:225:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:225:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `user_data_rhevm` of type `def user_data_rhevm(self) -> Unknown`
- tests/unittests/sources/test_altcloud.py:235:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
+ tests/unittests/sources/test_altcloud.py:235:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `user_data_vsphere` of type `def user_data_vsphere(self) -> Unknown`
- tests/unittests/sources/test_exoscale.py:72:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
+ tests/unittests/sources/test_exoscale.py:72:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
- tests/unittests/sources/test_exoscale.py:114:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
+ tests/unittests/sources/test_exoscale.py:114:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
- tests/unittests/sources/test_exoscale.py:150:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
+ tests/unittests/sources/test_exoscale.py:150:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
- tests/unittests/sources/test_exoscale.py:216:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
+ tests/unittests/sources/test_exoscale.py:216:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `ds_detect` of type `def ds_detect() -> Unknown`
+ tests/unittests/test_url_helper.py:518:31: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
+ tests/unittests/test_url_helper.py:527:31: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
+ tests/unittests/test_url_helper.py:585:32: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
+ tests/unittests/test_url_helper.py:593:32: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
- Found 1169 diagnostics
+ Found 1173 diagnostics

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/main.py:165:9: error[invalid-assignment] Object of type `(*args) -> Unknown` is not assignable to attribute `default_user_agent` of type `def default_user_agent(name: str = "python-requests") -> str`
+ cwltool/main.py:165:9: error[invalid-assignment] Object of type `(*args) -> str` is not assignable to attribute `default_user_agent` of type `def default_user_agent(name: str = "python-requests") -> str`

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

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/book_providers.py:829:9: error[invalid-argument-type] Argument to function `multisort_best` is incorrect: Expected `list[tuple[Literal["min", "max"], (Unknown | tuple[Edition, AbstractBookProvider[Unknown] | None], /) -> int | float]]`, found `list[Unknown | tuple[str, (rec) -> Unknown]]`
+ openlibrary/book_providers.py:829:9: error[invalid-argument-type] Argument to function `multisort_best` is incorrect: Expected `list[tuple[Literal["min", "max"], (Unknown | tuple[Edition, AbstractBookProvider[Unknown] | None], /) -> int | float]]`, found `list[Unknown | tuple[str, (rec) -> int | float]]`
- openlibrary/conftest.py:110:5: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `init_plugin` of type `def init_plugin() -> Unknown`
+ openlibrary/conftest.py:110:5: error[invalid-assignment] Object of type `() -> None` is not assignable to attribute `init_plugin` of type `def init_plugin() -> Unknown`

manticore (https://github.com/trailofbits/manticore)
- manticore/native/plugins.py:13:9: error[invalid-assignment] Object of type `(...) -> Unknown` is not assignable to attribute `_publish` on type `Unknown | None`
+ manticore/native/plugins.py:13:9: error[invalid-assignment] Object of type `(...) -> None` is not assignable to attribute `_publish` on type `Unknown | None`

xarray (https://github.com/pydata/xarray)
- xarray/tests/test_datatree_mapping.py:92:57: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- xarray/tests/test_datatree_mapping.py:104:62: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 1753 diagnostics
+ Found 1751 diagnostics

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/disasm/disassembly.py:97:53: error[invalid-assignment] Object of type `defaultdict[int, int | None]` is not assignable to `defaultdict[int, int]`
+ pwndbg/aglib/disasm/disassembly.py:102:60: error[invalid-assignment] Object of type `defaultdict[int, int | None]` is not assignable to `defaultdict[int, int]`
+ pwndbg/aglib/disasm/disassembly.py:105:79: error[invalid-assignment] Object of type `defaultdict[int, PwndbgInstruction | None]` is not assignable to `defaultdict[int, PwndbgInstruction]`
+ pwndbg/aglib/heap/ptmalloc.py:1414:20: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ pwndbg/aglib/heap/ptmalloc.py:1415:20: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ pwndbg/aglib/heap/ptmalloc.py:1416:28: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ pwndbg/aglib/heap/ptmalloc.py:1417:28: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- pwndbg/aglib/kernel/__init__.py:218:20: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | None` and `Literal[1]`
+ pwndbg/aglib/kernel/__init__.py:218:20: error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `Literal[1]`
- pwndbg/aglib/kernel/__init__.py:224:22: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | None` and `int`
+ pwndbg/aglib/kernel/__init__.py:224:22: error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `int`
+ pwndbg/dbg_mod/gdb/__init__.py:185:40: error[invalid-argument-type] Argument is incorrect: Expected `() -> T@selection`, found `() -> Frame`
+ pwndbg/dbg_mod/gdb/__init__.py:204:36: error[invalid-argument-type] Argument is incorrect: Expected `() -> T@selection`, found `() -> Frame`
+ pwndbg/dbg_mod/gdb/__init__.py:393:36: error[invalid-argument-type] Argument is incorrect: Expected `() -> T@selection`, found `() -> InferiorThread`
- pwndbg/gdblib/tui/context.py:221:24: error[invalid-assignment] Object of type `(...) -> Unknown` is not assignable to `def _ansi_substr(self, line: str, start_char: int, end_char: int) -> str`
+ pwndbg/gdblib/tui/context.py:221:24: error[invalid-assignment] Object of type `(...) -> Unknown | str` is not assignable to `def _ansi_substr(self, line: str, start_char: int, end_char: int) -> str`
- Found 2031 diagnostics
+ Found 2041 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/build_meta.py:107:5: error[invalid-assignment] Object of type `(attrs) -> Unknown` is not assignable to attribute `_install_setup_requires` of type `def _install_setup_requires(attrs) -> Unknown`
+ setuptools/build_meta.py:107:5: error[invalid-assignment] Object of type `(attrs) -> None` is not assignable to attribute `_install_setup_requires` of type `def _install_setup_requires(attrs) -> Unknown`

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/wrapper/_implementations.py:1735:52: error[invalid-assignment] Object of type `((x: str | None) -> object) | (((str | None, /) -> str | None) & ~Top[Mapping[Unknown, object]])` is not assignable to `(str | None, /) -> str | None`
- Found 522 diagnostics
+ Found 523 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/debugging/_debugger.py:269:13: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | DerivedVariable[int | float | Unknown]`
+ ddtrace/debugging/_debugger.py:269:13: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | DerivedVariable[int | float]`
- ddtrace/debugging/_redaction.py:123:12: warning[possibly-missing-attribute] Attribute `search` may be missing on object of type `(Unknown & ~None) | DerivedVariable[Unknown]`
+ ddtrace/debugging/_redaction.py:123:12: warning[possibly-missing-attribute] Attribute `search` may be missing on object of type `(Unknown & ~None) | DerivedVariable[Pattern[str] | None]`
- ddtrace/debugging/_signal/utils.py:227:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `((Any, /) -> bool) | ((_) -> Unknown)`
- ddtrace/debugging/_signal/utils.py:257:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `((Any, /) -> bool) | ((_) -> Unknown)`
- ddtrace/debugging/_signal/utils.py:313:41: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `((Any, /) -> bool) | ((_) -> Unknown)`
- ddtrace/debugging/_signal/utils.py:332:34: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `((Any, /) -> bool) | ((_) -> Unknown)`
- ddtrace/debugging/_signal/utils.py:358:37: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `((Any, /) -> bool) | ((_) -> Unknown)`
+ ddtrace/debugging/_signal/utils.py:227:38: error[unresolved-attribute] Object of type `(Any, /) -> bool` has no attribute `__name__`
+ ddtrace/debugging/_signal/utils.py:257:38: error[unresolved-attribute] Object of type `(Any, /) -> bool` has no attribute `__name__`
+ ddtrace/debugging/_signal/utils.py:313:41: error[unresolved-attribute] Object of type `(Any, /) -> bool` has no attribute `__name__`
+ ddtrace/debugging/_signal/utils.py:332:34: error[unresolved-attribute] Object of type `(Any, /) -> bool` has no attribute `__name__`
+ ddtrace/debugging/_signal/utils.py:358:37: error[unresolved-attribute] Object of type `(Any, /) -> bool` has no attribute `__name__`
- ddtrace/debugging/_uploader.py:80:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | DerivedVariable[str | Unknown]`
+ ddtrace/debugging/_uploader.py:80:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | DerivedVariable[str | (Unknown & ~AlwaysFalsy)]`
- ddtrace/debugging/_uploader.py:86:66: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | DerivedVariable[str | Unknown]`
+ ddtrace/debugging/_uploader.py:86:66: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | DerivedVariable[str | (Unknown & ~AlwaysFalsy)]`
- ddtrace/internal/symbol_db/symbols.py:527:34: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ ddtrace/internal/symbol_db/symbols.py:527:34: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- ddtrace/internal/symbol_db/symbols.py:545:36: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ ddtrace/internal/symbol_db/symbols.py:545:36: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
+ ddtrace/vendor/xmltodict.py:114:5: error[invalid-assignment] Object of type `(*x: str) -> Literal[1]` is not assignable to attribute `ExternalEntityRefHandler` of type `((str, str | None, str | None, str | None, /) -> int) | None`
+ tests/appsec/appsec/test_asm_request_context.py:99:9: error[invalid-argument-type] Argument is incorrect: Expected `(() -> bool) | None`, found `() -> Literal[42]`
- tests/ci_visibility/test_atr.py:74:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `efd_is_faulty_session` of type `def efd_is_faulty_session(self) -> Unknown`
+ tests/ci_visibility/test_atr.py:74:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `efd_is_faulty_session` of type `def efd_is_faulty_session(self) -> Unknown`
- tests/ci_visibility/test_atr.py:169:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `efd_is_faulty_session` of type `def efd_is_faulty_session(self) -> Unknown`
+ tests/ci_visibility/test_atr.py:169:9: error[invalid-assignment] Object of type `() -> Literal[False]` is not assignable to attribute `efd_is_faulty_session` of type `def efd_is_faulty_session(self) -> Unknown`
- tests/ci_visibility/test_atr.py:175:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `get_session` of type `def get_session(self) -> TestVisibilitySession | None`
+ tests/ci_visibility/test_atr.py:175:9: error[invalid-assignment] Object of type `() -> TestVisibilitySession` is not assignable to attribute `get_session` of type `def get_session(self) -> TestVisibilitySession | None`
- tests/debugging/mocking.py:195:9: error[invalid-assignment] Object of type `(_) -> Unknown` is not assignable to attribute `register` of type `def register[**_P, _T](func: (**_P@register) -> _T, /, *args: _P.args, **kwargs: _P.kwargs) -> (**_P@register) -> _T`
+ tests/debugging/mocking.py:195:9: error[invalid-assignment] Object of type `(_) -> None` is not assignable to attribute `register` of type `def register[**_P, _T](func: (**_P@register) -> _T, /, *args: _P.args, **kwargs: _P.kwargs) -> (**_P@register) -> _T`
- tests/internal/symbol_db/test_config.py:8:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:8:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/internal/symbol_db/test_config.py:9:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:9:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/internal/symbol_db/test_config.py:10:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:10:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/internal/symbol_db/test_config.py:12:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:12:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/internal/symbol_db/test_config.py:13:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:13:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/internal/symbol_db/test_config.py:14:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Unknown]`
+ tests/internal/symbol_db/test_config.py:14:12: warning[possibly-missing-attribute] Attribute `match` may be missing on object of type `Unknown | DerivedVariable[Pattern[Unknown] | Pattern[str]]`
- tests/testing/internal/test_telemetry.py:396:9: error[invalid-assignment] Object of type `() -> Unknown` is not assignable to attribute `is_benchmark` of type `def is_benchmark(self) -> bool`
+ tests/testing/internal/test_telemetry.py:396:9: error[invalid-assignment] Object of type `() -> Literal[True]` is not assignable to attribute `is_benchmark` of type `def is_benchmark(self) -> bool`
- Found 8244 diagnostics
+ Found 8246 diagnostics

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/client_reqrep.py:211:66: error[invalid-assignment] Object of type `(*_: ClientResponse) -> Literal["utf-8"]` is not assignable to `(ClientResponse, bytes, /) -> str`
- Found 181 diagnostics
+ Found 182 diagnostics

pycryptodome (https://github.com/Legrandin/pycryptodome)
- lib/Crypto/SelfTest/Protocol/test_KDF.py:142:26: error[invalid-argument-type] Argument to function `PBKDF2` is incorrect: Expected `((int, /) -> bytes) | None`, found `(p, s) -> Unknown`
+ lib/Crypto/SelfTest/Protocol/test_KDF.py:142:26: error[invalid-argument-type] Argument to function `PBKDF2` is incorrect: Expected `((int, /) -> bytes) | None`, found `(p: int, s) -> bytes`

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 46 diagnostics
+ Found 47 diagnostics

django-stubs (https://github.com/typeddjango/django-stubs)
- tests/assert_type/apps/test_config.py:38:1: error[type-assertion-failure] Type `str` does not match asserted type `Unknown`
+ tests/assert_type/apps/test_config.py:38:1: error[type-assertion-failure] Type `str` does not match asserted type `Unknown | Literal["django.db.models.BigAutoField"]`

cryptography (https://github.com/pyca/cryptography)
- tests/hazmat/primitives/test_dsa.py:940:33: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_dsa.py:955:35: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_dsa.py:970:33: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1020:33: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1036:35: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1052:33: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1363:33: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1411:35: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/hazmat/primitives/test_ec.py:1646:51: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 36 diagnostics
+ Found 27 diagnostics

jax (https://github.com/google/jax)
- jax/_src/ad_checkpoint.py:805:16: error[unresolved-attribute] Unresolved attribute `in_cts_zero` on type `() -> Unknown`
+ jax/_src/ad_checkpoint.py:805:16: error[unresolved-attribute] Unresolved attribute `in_cts_zero` on type `() -> None`
- jax/_src/ad_checkpoint.py:814:28: error[unresolved-attribute] Object of type `() -> Unknown` has no attribute `in_cts_zero`
+ jax/_src/ad_checkpoint.py:814:28: error[unresolved-attribute] Object of type `() -> None` has no attribute `in_cts_zero`
- jax/_src/ad_checkpoint.py:969:32: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x, *, name) -> Unknown`
+ jax/_src/ad_checkpoint.py:969:32: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x, *, name) -> list[Unknown]`
- jax/_src/error_check.py:278:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_SerializeAuxData`, found `(x) -> Unknown`
+ jax/_src/error_check.py:278:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_SerializeAuxData`, found `(x) -> bytes`
- jax/_src/error_check.py:281:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_DeserializeAuxData`, found `(x) -> Unknown`
+ jax/_src/error_check.py:281:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_DeserializeAuxData`, found `(x) -> Any`
- jax/_src/export/_export.py:535:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_DeserializeAuxData`, found `(b) -> Unknown`
+ jax/_src/export/_export.py:535:5: error[invalid-argument-type] Argument to function `register_pytree_node_serialization` is incorrect: Expected `_DeserializeAuxData`, found `(b) -> Any`
- jax/_src/hijax.py:454:7: error[unresolved-attribute] Unresolved attribute `out_nzs` on type `() -> Unknown`
+ jax/_src/hijax.py:454:7: error[unresolved-attribute] Unresolved attribute `out_nzs` on type `() -> None`
- jax/_src/interpreters/mlir.py:2829:44: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x) -> Unknown`
+ jax/_src/interpreters/mlir.py:2829:44: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x) -> list[Unknown]`
- jax/_src/lax/lax.py:5121:37: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(_, x, **__) -> Unknown`
+ jax/_src/lax/lax.py:5121:37: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(_, x, **__) -> list[Unknown]`
- jax/_src/lax/lax.py:5160:39: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(_, x, **__) -> Unknown`
+ jax/_src/lax/lax.py:5160:39: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(_, x, **__) -> list[Unknown]`
- jax/_src/lax/lax.py:8473:32: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x) -> Unknown`
+ jax/_src/lax/lax.py:8473:32: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x) -> list[Unknown]`
- jax/_src/lax/lax.py:8492:36: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, _) -> Unknown`
+ jax/_src/lax/lax.py:8492:36: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, _) -> list[Unknown]`
- jax/_src/lax/lax.py:8959:31: error[invalid-argument-type] Argument to function `register_lowering` is incorrect: Expected `LoweringRule`, found `(ctx, x, y) -

... (truncated 279 lines) ...
Memory usage changes were detected when running on open source projects
prefect (https://github.com/PrefectHQ/prefect)
-     memo fields = ~424MB
+     memo fields = ~445MB

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 16, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 29 18 102
invalid-assignment 13 0 46
unused-ignore-comment 0 23 0
possibly-missing-attribute 4 5 9
invalid-return-type 2 4 5
unresolved-attribute 5 0 5
type-assertion-failure 0 5 1
unsupported-operator 5 0 0
not-subscriptable 4 0 0
no-matching-overload 3 0 0
invalid-await 1 0 0
Total 66 55 168

Full report with detailed diff (timing results)

reveal_type(self.c)

# revealed: (*, kw_only=...) -> Unknown
# revealed: (*, kw_only=...) -> Unknown | ((*, kw_only=...) -> Unknown) | ((*, kw_only=...) -> Divergent) | ((*, kw_only=...) -> Divergent)
Copy link
Member Author

Choose a reason for hiding this comment

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

The revealed type here is a little unfortunate. Ideally it would just be () -> Unknown | (() -> Divergent), but I'm not sure that is an issue related to this PR.

@AlexWaygood
Copy link
Member

This PR is stacked on #22564.

The weird typing- conformance comment should be fixed if you rebase that PR on main, and then this PR on that PR (sorry for the teething problems there with the new workflow...)

@MichaReiser
Copy link
Member

There seems to be a new fuzzer panic

@ibraheemdev ibraheemdev force-pushed the ibraheem/comprehension-tcx branch from fa2b058 to 109d2a5 Compare January 19, 2026 23:26
@ibraheemdev ibraheemdev force-pushed the ibraheem/lambda-tcx branch 2 times, most recently from af62f6c to 7d33c41 Compare January 19, 2026 23:27
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

Merging this PR will not alter performance

✅ 23 untouched benchmarks
⏩ 30 skipped benchmarks1


Comparing ibraheem/lambda-tcx (d050295) with main (009bbb5)

Open in CodSpeed

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.

@ibraheemdev ibraheemdev marked this pull request as draft January 19, 2026 23:56
Base automatically changed from ibraheem/comprehension-tcx to main January 20, 2026 20:25
@ibraheemdev ibraheemdev marked this pull request as ready for review January 20, 2026 21:04
@ibraheemdev
Copy link
Member Author

ibraheemdev commented Jan 20, 2026

There is one new fuzzer panic:

lambda: name_4

@lambda: name_5
class name_1:
    pass

name_2 = [lambda: name_4, name_1]

if name_2:
    @(*name_2,)
    class name_3:
        pass
    assert unique_name_19

@lambda: name_3
class name_4[*name_2](0, name_1=name_3):
    pass
try:
    [name_5, name_4] = *name_4, = name_4
except* 0:
    pass
else:
    async def name_4():
        pass

for name_3 in name_4:
    pass
Salsa trace
error[panic]: Panicked at ~/.cargo/git/checkouts/salsa-e6f3bb7c2a062968/9860ff6/src/function/execute.rs:635:9 when checking `~/sandbox/main.py`: `infer_definition_types(Id(1406)): execute: too many cycle iterations`
info: This indicates a bug in ty.
info: If you could open an issue at https://github.com/astral-sh/ty/issues/new?title=%5Bpanic%5D, we'd be very appreciative!
info: Platform: linux x86_64
info: Version: ruff/0.14.13+103 (a8bb4fcbf 2026-01-20)
info: Args: ["~/ruff/target/debug/ty", "check", "main.py"]
info: run with `RUST_BACKTRACE=1` environment variable to show the full backtrace information
info: query stacktrace:
   0: infer_expression_types_impl(Id(1803))
             at crates/ty_python_semantic/src/types/infer.rs:240
             cycle heads: static_expression_truthiness(Id(1801)) -> iteration = 200, infer_definition_types(Id(1404)) -> iteration = 200
   1: infer_definition_types(Id(1409))
             at crates/ty_python_semantic/src/types/infer.rs:69
   2: place_by_id(Id(2007))
             at crates/ty_python_semantic/src/place.rs:898
             cycle heads: static_expression_truthiness(Id(1800)) -> iteration = 200, infer_definition_types(Id(1402)) -> iteration = 200, static_expression_truthiness(Id(1801)) -> iteration = 200
   3: infer_scope_types_impl(Id(1006))
             at crates/ty_python_semantic/src/types/infer.rs:192
   4: infer_definition_types(Id(1404))
             at crates/ty_python_semantic/src/types/infer.rs:69
   5: infer_expression_types_impl(Id(1802))
             at crates/ty_python_semantic/src/types/infer.rs:240
             cycle heads: static_expression_truthiness(Id(1801)) -> iteration = 200
   6: infer_unpack_types(Id(1c00))
             at crates/ty_python_semantic/src/types/infer.rs:498
   7: infer_definition_types(Id(1405))
             at crates/ty_python_semantic/src/types/infer.rs:69
             cycle heads: static_expression_truthiness(Id(1801)) -> iteration = 200
   8: place_by_id(Id(2006))
             at crates/ty_python_semantic/src/place.rs:898
             cycle heads: static_expression_truthiness(Id(1801)) -> iteration = 200
   9: infer_scope_types_impl(Id(1002))
             at crates/ty_python_semantic/src/types/infer.rs:192
  10: infer_definition_types(Id(1400))
             at crates/ty_python_semantic/src/types/infer.rs:69
  11: StaticClassLiteral < 'db >::decorators_(Id(501e))
             at crates/ty_python_semantic/src/types/class.rs:2136
  12: Type < 'db >::class_member_with_policy_(Id(9c2b))
             at crates/ty_python_semantic/src/types.rs:879
  13: Type < 'db >::member_lookup_with_policy_(Id(3c3f))
             at crates/ty_python_semantic/src/types.rs:879
  14: is_redundant_with_impl(Id(8c6e))
             at crates/ty_python_semantic/src/types/relation.rs:297
  15: infer_definition_types(Id(1402))
             at crates/ty_python_semantic/src/types/infer.rs:69
             cycle heads: static_expression_truthiness(Id(1800)) -> iteration = 200, infer_definition_types(Id(1401)) -> iteration = 200, is_redundant_with_impl(Id(8c37)) -> iteration = 200
  16: infer_scope_types_impl(Id(1007))
             at crates/ty_python_semantic/src/types/infer.rs:192
             cycle heads: static_expression_truthiness(Id(1801)) -> iteration = 200, static_expression_truthiness(Id(1800)) -> iteration = 200
  17: StaticClassLiteral < 'db >::explicit_bases_(Id(501d))
             at crates/ty_python_semantic/src/types/class.rs:2136
  18: StaticClassLiteral < 'db >::try_metaclass_(Id(501d))
             at crates/ty_python_semantic/src/types/class.rs:2136
  19: is_redundant_with_impl(Id(8c37))
             at crates/ty_python_semantic/src/types/relation.rs:297
  20: infer_scope_types_impl(Id(1004))
             at crates/ty_python_semantic/src/types/infer.rs:192
             cycle heads: place_by_id(Id(2000)) -> iteration = 200
  21: infer_definition_types(Id(1401))
             at crates/ty_python_semantic/src/types/infer.rs:69
  22: infer_expression_types_impl(Id(1800))
             at crates/ty_python_semantic/src/types/infer.rs:240
  23: static_expression_truthiness(Id(1800))
             at crates/ty_python_semantic/src/types/infer.rs:467
  24: infer_expression_types_impl(Id(1801))
             at crates/ty_python_semantic/src/types/infer.rs:240
  25: static_expression_truthiness(Id(1801))
             at crates/ty_python_semantic/src/types/infer.rs:467
  26: place_by_id(Id(2000))
             at crates/ty_python_semantic/src/place.rs:898
  27: infer_scope_types_impl(Id(1001))
             at crates/ty_python_semantic/src/types/infer.rs:192
  28: infer_scope_types_impl(Id(1000))
             at crates/ty_python_semantic/src/types/infer.rs:192
  29: check_file_impl(Id(c00))
             at crates/ty_project/src/lib.rs:554

We are now inferring the lambda bodies eagerly while inferring the outer scope, and so there is a cyclic dependency between name_2 and name_4, but I can't seem to minimize it beyond the snippet. The full traces shows the following cycle, which never converges:

infer_definition_types(Id(1406)) -> infer_definition_types(Id(1407)) ->
  infer_definition_types(Id(1406)) -> infer_unpack_types(Id(1c00)) ->
  infer_definition_types(Id(1406)) -> infer_definition_types(Id(1407)) -> ...

@dcreager
Copy link
Member

There is still a fuzzer panic on this. I'm going to move it to draft until that is resolved.

@dcreager dcreager marked this pull request as draft February 13, 2026 14:17
mtshiba pushed a commit to mtshiba/ruff that referenced this pull request Mar 6, 2026
Detailed analysis of the panic caused by eagerly inferring lambda bodies
as part of their parent scope's inference. The cycle involves circular
dependencies between name_4, name_2, name_3 through lambda body
references, unpack assignments, and class decorators.

Root cause: eager lambda body inference creates new dependency edges that
form non-converging cycles when lambda bodies reference names involved in
circular definition chains.

https://claude.ai/code/session_01Unrae9uHg8UZ2um1EKH3py
mtshiba pushed a commit that referenced this pull request Mar 6, 2026
…context

When `infer_lambda_expression` eagerly infers the lambda body via
`infer_scope_types`, it can introduce cycle edges: the lambda body may
reference names whose definitions depend on this very expression (e.g.
a lambda used as a decorator on a class that is referenced transitively
by the lambda body). Without a Callable type context, the inferred
return type participates in the cycle and can oscillate between
iterations, causing a "too many cycle iterations" panic.

Fix: only use the inferred body return type when a direct Callable type
context is available (the main feature of PR #22633). Without a type
context, fall back to `Unknown` for the return type while still
inferring the body for diagnostics (reveal_type, etc.).

https://claude.ai/code/session_0148KoTarLuZRPBttHzmZYEU
carljm added a commit that referenced this pull request Mar 10, 2026
## Summary

There are some issues with our current cycle handling, particularly with
our implementation of `Type::cycle_normalized`.

To prevent values ​​from oscillating endlessly within a fixed-point
iteration, `cycle_normalized` unions the type of the previous iteration
with the current type. This ensures monotonicity of the type inference
calculation.
However, we've observed that always applying this union can sometimes
produce undesirable results. Therefore, we make some exceptions where
this union isn't applied (see #21909, #21910).
However, these prescriptions are likely not exhaustive, and #22794 also
confirmed the occurrence of "divergent pollution" when narrowing. The
core issue in #22794 is that `Divergent` can inhibit narrowing. The
result type itself does not contain `Divergent`, but `Divergent`
indirectly affects it.
This suggests that determining whether a type contains `Divergent` is
not a perfect indicator of "taintedness".

After carefully examining these cases, I found that the problematic
"low-precision types" only appear in the first few iterations:
`Divergent` itself and the type of the next iteration constructed by
referencing it. Therefore, we shouldn't union these few iterations. I
found that this simple change can remove all of the exceptional handling
for `Divergent` introduced in #21909, #21910, and #22794.

I also found that this change removes the too-many-cycle panic blocking
#22633.

## Test Plan

mdtest updated

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
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.

4 participants