Skip to content

[ty] Infer yield expression#23796

Merged
sharkdp merged 17 commits intoastral-sh:mainfrom
Glyphack:shaygan-yield-type
Mar 20, 2026
Merged

[ty] Infer yield expression#23796
sharkdp merged 17 commits intoastral-sh:mainfrom
Glyphack:shaygan-yield-type

Conversation

@Glyphack
Copy link
Copy Markdown
Contributor

@Glyphack Glyphack commented Mar 7, 2026

Summary

Infer yield and yield from expression using function annotation.

Part of astral-sh/ty#1718

Remaining part is checking return types, I'm planning to do that in a separate PR.
All the remaining conformance tests are because of the return type checking.

Notes

Mixing Generator and Async Generator is allowed.

def async_returns_generator() -> Generator[int, int, None] | AsyncGenerator[int, int]:
    x = yield 1
    reveal_type(x)
    return None

I was not sure if there's valid use case for this or not.
But I found this code and mypy allows this. So I'm not doing any checks for this case. Just the normal logic that unions the types.
Pyright rejects this.

Test Plan

I checked ecosystem results locally. There are new diagnostics added because we are now verifying that type of yielded value can be assigned annotated function type.
I can revert this if you think it would be too noisy to have it right now.

image

Added todo case for when return type does not match:

from typing import Generator

def invalid_return_type() -> Generator[None, None, None]:
    yield
    # TODO: error: [invalid-return-type]
    return ""

@Glyphack Glyphack changed the title Infer yield expression [ty] Infer yield expression Mar 7, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 7, 2026

Typing conformance results improved 🎉

The percentage of diagnostics emitted that were expected errors increased from 85.29% to 85.38%. The percentage of expected errors that received a diagnostic increased from 78.13% to 78.70%. The number of fully passing files held steady at 64/132.

Summary

How are test cases classified?

Each test case represents one expected error annotation or a group of annotations sharing a tag. Counts are per test case, not per diagnostic — multiple diagnostics on the same line count as one. Required annotations (E) are true positives when ty flags the expected location and false negatives when it does not. Optional annotations (E?) are true positives when flagged but true negatives (not false negatives) when not. Tagged annotations (E[tag]) require ty to flag exactly one of the tagged lines; tagged multi-annotations (E[tag+]) allow any number up to the tag count. Flagging unexpected locations counts as a false positive.

Metric Old New Diff Outcome
True Positives 829 835 +6 ⏫ (✅)
False Positives 143 143 +0
False Negatives 232 226 -6 ⏬ (✅)
Total Diagnostics 1049 1055 +6
Precision 85.29% 85.38% +0.09% ⏫ (✅)
Recall 78.13% 78.70% +0.57% ⏫ (✅)
Passing Files 64/132 64/132 +0

Test file breakdown

1 file altered
File True Positives False Positives False Negatives Status
annotations_generators.py 8 (+6) ✅ 0 2 (-6) ✅ 📈 Improving
Total (all files) 835 (+6) ✅ 143 226 (-6) ✅ 64/132

True positives added (6)

6 diagnostics
Test case Diff

annotations_generators.py:118

+error[invalid-yield] Yield type `A` does not match annotated yield type `B`

annotations_generators.py:119

+error[invalid-yield] Yield type `int` does not match annotated yield type `B`

annotations_generators.py:135

+error[invalid-yield] Send type `int` does not match annotated send type `str`

annotations_generators.py:57

+error[invalid-yield] Yield type `Literal[3]` does not match annotated yield type `A`

annotations_generators.py:66

+error[invalid-yield] Yield type `Literal[3]` does not match annotated yield type `A`

annotations_generators.py:75

+error[invalid-yield] Yield type `B` does not match annotated yield type `A`

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 7, 2026

mypy_primer results

Changes were detected when running on open source projects
bidict (https://github.com/jab/bidict)
+ bidict/_iter.py:26:20: error[invalid-assignment] Object of type `tuple[object, object]` is not assignable to `tuple[KT@iteritems, VT@iteritems]`
+ bidict/_iter.py:28:20: error[invalid-assignment] Object of type `tuple[object, object]` is not assignable to `tuple[KT@iteritems, VT@iteritems]`
- Found 17 diagnostics
+ Found 19 diagnostics

pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/grammar.py:399:13: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[str, str]`, found `None`
- Found 48 diagnostics
+ Found 49 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/structures.py:33:20: error[invalid-assignment] Object of type `tuple[object, object]` is not assignable to `tuple[K@iter_multi_items, V@iter_multi_items]`
+ src/werkzeug/datastructures/structures.py:38:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[K@iter_multi_items, V@iter_multi_items]`, found `tuple[object, object]`
+ src/werkzeug/datastructures/structures.py:40:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[K@iter_multi_items, V@iter_multi_items]`, found `tuple[object, ~Top[list[Unknown]] & ~tuple[object, ...] & ~Top[set[Unknown]]]`
+ src/werkzeug/test.py:167:20: error[invalid-assignment] Object of type `None` is not assignable to `Never`
- Found 387 diagnostics
+ Found 391 diagnostics

black (https://github.com/psf/black)
+ src/black/trans.py:502:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Ok[Line] | Err[CannotTransform]`, found `Ok[object]`
- Found 44 diagnostics
+ Found 45 diagnostics

boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:602:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `T@iter_underlying`, found `object`
- Found 23 diagnostics
+ Found 24 diagnostics

starlette (https://github.com/encode/starlette)
+ tests/test_applications.py:110:11: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `CustomState`, found `dict[str, int]`
+ tests/test_routing.py:697:9: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Never`, found `None`
- Found 197 diagnostics
+ Found 199 diagnostics

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/asyncgen.py:19:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `_T@as_async_generator`, found `object`
- Found 1794 diagnostics
+ Found 1795 diagnostics

pylint (https://github.com/pycqa/pylint)
+ pylint/checkers/utils.py:2055:28: error[invalid-assignment] Object of type `None` is not assignable to `Never`
+ pylint/checkers/utils.py:2067:28: error[invalid-assignment] Object of type `None` is not assignable to `Never`
+ pylint/checkers/utils.py:2070:28: error[invalid-assignment] Object of type `None` is not assignable to `Never`
- Found 222 diagnostics
+ Found 225 diagnostics

kopf (https://github.com/nolar/kopf)
+ kopf/_cogs/clients/watching.py:175:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Bookmark | RawEvent`, found `dict[str, None | RawBody]`
+ kopf/_cogs/structs/dicts.py:261:28: error[invalid-assignment] Object of type `None` is not assignable to `Never`
- Found 294 diagnostics
+ Found 296 diagnostics

httpx-caching (https://github.com/johtso/httpx-caching)
+ httpx_caching/_policy.py:126:46: error[invalid-assignment] Object of type `Response` is not assignable to `tuple[Response, dict[Unknown, Unknown]]`
- httpx_caching/_policy.py:216:76: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- httpx_caching/_policy.py:233:60: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 27 diagnostics
+ Found 26 diagnostics

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/porcelain/__init__.py:4861:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `str`, found `str | bytes | PathLike[str]`
- Found 231 diagnostics
+ Found 232 diagnostics

PyGithub (https://github.com/PyGithub/PyGithub)
- github/PaginatedList.py:125:47: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 410 diagnostics
+ Found 409 diagnostics

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/engine/core.py:134:50: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 337 diagnostics
+ Found 336 diagnostics

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/internal/mappings.py:240:28: error[invalid-assignment] Object of type `tuple[str, object]` is not assignable to `tuple[str, V@TypedBox]`
- Found 155 diagnostics
+ Found 156 diagnostics

Expression (https://github.com/cognitedata/Expression)
+ README.py:358:20: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ README.py:382:20: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ README.py:385:20: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ README.py:455:20: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ README.py:456:20: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ expression/core/option.py:308:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `_TSourceOut@Option`, found `None`
+ expression/core/result.py:267:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `_TSourceOut@Result`, found `None`
+ tests/test_catch.py:72:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_catch.py:83:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_catch.py:99:24: error[invalid-assignment] Object of type `str` is not assignable to `None`
+ tests/test_option_builder.py:43:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:107:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:123:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:136:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:159:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:218:9: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Option[int]`, found `None`
+ tests/test_option_builder.py:269:32: error[invalid-assignment] Object of type `str` is not assignable to `None`
+ tests/test_option_builder.py:285:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_option_builder.py:288:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:42:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:106:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:122:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:139:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:162:29: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:221:9: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Result[int, str]`, found `None`
+ tests/test_result_builder.py:277:32: error[invalid-assignment] Object of type `str` is not assignable to `None`
+ tests/test_result_builder.py:293:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_result_builder.py:296:24: error[invalid-assignment] Object of type `int` is not assignable to `None`
+ tests/test_seq_builder.py:186:9: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `Iterable[int]`, found `None`
- Found 210 diagnostics
+ Found 239 diagnostics

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/clients.py:2720:13: error[invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `@Todo` on object of type `dict[str, ModuleType]`
+ tanjun/clients.py:2720:13: error[invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `ModuleType` on object of type `dict[str, ModuleType]`
- tanjun/clients.py:2720:13: error[invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `@Todo` on object of type `dict[Path, ModuleType]`
+ tanjun/clients.py:2720:13: error[invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `ModuleType` on object of type `dict[Path, ModuleType]`

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_compat.py:47:13: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `str | Interpolation`, found `None`
- Found 669 diagnostics
+ Found 670 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
+ discord/abc.py:1821:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `PinnedMessage`, found `Message`
+ discord/ext/commands/cog.py:461:32: error[invalid-assignment] Object of type `Command[Never, (...), Any]` is not assignable to `Command[Self@walk_commands, (...), Any]`
+ discord/ext/commands/core.py:1455:28: error[invalid-assignment] Object of type `Command[Never, (...), Any]` is not assignable to `Command[CogT@GroupMixin, (...), Any]`
+ discord/utils.py:1046:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `list[T@_chunk]`, found `list[object]`
- Found 558 diagnostics
+ Found 562 diagnostics

vision (https://github.com/pytorch/vision)
+ test/datasets_utils.py:385:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[VisionDataset, dict[str, Any]]`, found `tuple[Unknown, Unknown | None]`
- Found 1418 diagnostics
+ Found 1419 diagnostics

trio (https://github.com/python-trio/trio)
+ src/trio/_tests/test_ssl.py:184:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `SSLStream[Stream]`, found `SSLStream[SocketStream]`
- Found 469 diagnostics
+ Found 470 diagnostics

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/process.py:315:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `MutableMapping[str, None | int | str | ... omitted 3 union elements]`, found `(MutableMapping[str, None | int | str | ... omitted 3 union elements] & Top[dict[Unknown, Unknown]]) | (MutableSequence[MutableMapping[str, None | int | str | ... omitted 3 union elements]] & Top[dict[Unknown, Unknown]])`
- Found 506 diagnostics
+ Found 507 diagnostics

xarray (https://github.com/pydata/xarray)
+ xarray/core/dataset.py:2675:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Hashable, int | slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[Any]] | Variable]`, found `tuple[Hashable, _arrayfunction[Any, Any] | _arrayapi[Any, Any] | ndarray[tuple[Any, ...], dtype[Unknown]] | Unknown]`
- Found 1712 diagnostics
+ Found 1713 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
+ src/integrations/prefect-redis/tests/test_messaging.py:76:11: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `prefect_redis.messaging.Cache`, found `prefect.server.utilities.messaging.Cache`
- Found 5880 diagnostics
+ Found 5881 diagnostics

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/macho.py:406:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `bytes`, found `bytearray`
+ pwndbg/aglib/macho.py:578:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[bytes, int]`, found `tuple[bytearray, int]`
+ pwndbg/commands/rop.py:197:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[str, Page | None]`, found `tuple[str | None, None]`
- Found 1872 diagnostics
+ Found 1875 diagnostics

aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/cookiejar.py:592:25: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 197 diagnostics
+ Found 196 diagnostics

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/plugins/openlibrary/lists.py:123:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AnnotatedSeedDict`, found `dict[str, ThingReferenceDict & Top[dict[Unknown, Unknown]]]`
+ openlibrary/plugins/openlibrary/lists.py:125:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AnnotatedSeedDict`, found `dict[str, dict[str, ThingReferenceDict | str | AnnotatedSeedDict]]`
- Found 1153 diagnostics
+ Found 1155 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ tests/debugging/mocking.py:199:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `TestDebugger`, found `Debugger`
+ tests/debugging/mocking.py:234:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `MockSignalUploader`, found `Unknown | SignalUploader | None`
- Found 9276 diagnostics
+ Found 9278 diagnostics

ibis (https://github.com/ibis-project/ibis)
+ ibis/expr/rewrites.py:183:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `ibis.expr.operations.core.Value[Unknown, Any]`, found `ibis.expr.types.generic.Value`
+ ibis/util.py:703:15: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `type[S@get_subclasses]`, found `type[T@get_subclasses]`
- Found 4888 diagnostics
+ Found 4890 diagnostics

pandas (https://github.com/pandas-dev/pandas)
- pandas/io/formats/format.py:1069:20: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 4584 diagnostics
+ Found 4583 diagnostics

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/memory_measure.py:241:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[tuple[str, ...], list[int]]`, found `tuple[str, list[Unknown]]`
- static_frame/core/quilt.py:859:45: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/type_blocks.py:878:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[dtype[Any], int]`, found `tuple[None | Unknown, int | Unknown]`
+ static_frame/core/type_blocks.py:1280:24: error[invalid-assignment] Object of type `tuple[Hashable, slice[Any, Any, Any], TypeBlocks | ndarray[Any, Any]]` is not assignable to `tuple[ndarray[Any, Any], ndarray[Any, Any] | slice[Any, Any, Any], TypeBlocks]`
+ static_frame/core/type_blocks.py:1282:24: error[invalid-assignment] Object of type `tuple[Hashable, ndarray[Any, Any], TypeBlocks | ndarray[Any, Any]]` is not assignable to `tuple[ndarray[Any, Any], ndarray[Any, Any] | slice[Any, Any, Any], TypeBlocks]`
+ static_frame/core/type_blocks.py:1303:24: error[invalid-assignment] Object of type `tuple[Hashable, slice[Any, Any, Any], TypeBlocks | ndarray[Any, Any]]` is not assignable to `tuple[Hashable, ndarray[Any, Any] | slice[Any, Any, Any], ndarray[Any, Any]]`
+ static_frame/core/type_blocks.py:1312:24: error[invalid-assignment] Object of type `tuple[Hashable, ndarray[Any, Any], TypeBlocks | ndarray[Any, Any]]` is not assignable to `tuple[Hashable, ndarray[Any, Any] | slice[Any, Any, Any], ndarray[Any, Any]]`
+ static_frame/core/type_blocks.py:2923:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Any, ...]`, found `Sequence[Any] | @Todo`
+ static_frame/core/type_blocks.py:2926:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Any, ...]`, found `Sequence[Any] | @Todo`
+ static_frame/core/type_blocks.py:2937:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Any, ...]`, found `Sequence[Any] | @Todo`
+ static_frame/core/type_blocks.py:2985:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Any, ...]`, found `Sequence[Any] | @Todo`
- static_frame/test/integration/test_field_stats.py:61:78: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/test/unit/test_frame.py:6641:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[int, tuple[int, int]]`, found `tuple[int, ndarray[tuple[Any, ...], dtype[Any]]]`
+ static_frame/test/unit/test_frame.py:16347:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `tuple[Hashable, dict[Hashable, Any]]`, found `tuple[str, dict[str, int]]`
+ static_frame/test/unit/test_store_zip.py:310:24: error[invalid-assignment] Object of type `tuple[Hashable, Frame]` is not assignable to `tuple[str, Frame]`
- Found 1870 diagnostics
+ Found 1881 diagnostics

rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/aggregator.py:1282:55: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 2154 diagnostics
+ Found 2153 diagnostics

core (https://github.com/home-assistant/core)
+ homeassistant/components/anthropic/entity.py:474:35: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/anthropic/entity.py:477:31: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/anthropic/entity.py:490:31: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/anthropic/entity.py:492:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/anthropic/entity.py:499:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/anthropic/entity.py:504:31: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/anthropic/entity.py:507:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/anthropic/entity.py:518:31: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/anthropic/entity.py:521:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/anthropic/entity.py:542:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/anthropic/entity.py:545:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str | Unknown | dict[str, dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements]] | dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]`
+ homeassistant/components/anthropic/entity.py:569:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/anthropic/entity.py:577:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/anthropic/entity.py:580:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/anthropic/entity.py:592:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
+ homeassistant/components/anthropic/entity.py:612:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/backup/manager.py:1803:35: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `bytes`, found `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | (bytes & ~AlwaysFalsy)`
+ homeassistant/components/backup/manager.py:1953:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `bytes`, found `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | (bytes & ~AlwaysFalsy)`
+ homeassistant/components/cloud/entity.py:271:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/cloud/entity.py:283:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/cloud/entity.py:292:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/cloud/entity.py:304:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
+ homeassistant/components/cloud/entity.py:314:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str | Any | dict[str, Any]]`
+ homeassistant/components/cloud/entity.py:322:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Any]`
+ homeassistant/components/cloud/entity.py:342:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Any]`
+ homeassistant/components/cloud/entity.py:353:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/cloud/entity.py:356:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Any]`
+ homeassistant/components/cloud/entity.py:363:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/cloud/entity.py:375:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
+ homeassistant/components/google_generative_ai_conversation/entity.py:351:27: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/google_generative_ai_conversation/entity.py:353:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/google_generative_ai_conversation/entity.py:445:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict`, found `dict[str, ContentDetails]`
+ homeassistant/components/openai_conversation/entity.py:287:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/openai_conversation/entity.py:299:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/openai_conversation/entity.py:304:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/openai_conversation/entity.py:314:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
+ homeassistant/components/openai_conversation/entity.py:327:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str | Unknown | dict[str, list[Unknown] | None]]`
+ homeassistant/components/openai_conversation/entity.py:341:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
+ homeassistant/components/openai_conversation/entity.py:353:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str | Unknown | dict[str, Unknown]]`
+ homeassistant/components/openai_conversation/entity.py:361:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/openai_conversation/entity.py:380:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/openai_conversation/entity.py:390:23: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, str]`
+ homeassistant/components/openai_conversation/entity.py:393:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, Unknown]`
+ homeassistant/components/openai_conversation/entity.py:398:19: error[invalid-return-type] Yielded type does not match annotated yield type: expected yielded type assignable to `AssistantContentDeltaDict | ToolResultContentDeltaDict`, found `dict[str, list[ToolInput]]`
- Found 12076 diagnostics
+ Found 12120 diagnostics

scipy (https://github.com/scipy/scipy)
- subprojects/array_api_extra/tests/conftest.py:124:32: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 7989 diagnostics
+ Found 7988 diagnostics

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 7, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 705.27MB 705.40MB +0.02% (130.29kB)
sphinx 263.34MB 263.36MB +0.01% (21.02kB)
flake8 48.15MB 48.17MB +0.04% (20.78kB)
trio 116.27MB 116.28MB +0.01% (8.22kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
FunctionType<'db>::last_definition_raw_signature_ 3.27MB 3.37MB +2.76% (92.71kB)
infer_scope_types_impl 53.52MB 53.55MB +0.06% (33.07kB)
infer_definition_types 90.81MB 90.81MB +0.00% (1.62kB)
infer_expression_types_impl 56.17MB 56.17MB +0.00% (1.31kB)
StaticClassLiteral<'db>::try_mro_ 6.11MB 6.11MB +0.02% (1.08kB)
enum_metadata 2.76MB 2.76MB -0.02% (708.00B)
FunctionType<'db>::signature_ 3.94MB 3.94MB +0.01% (568.00B)
CallableType 1.70MB 1.70MB +0.03% (504.00B)
cached_protocol_interface 394.05kB 393.66kB -0.10% (408.00B)
Specialization 2.54MB 2.54MB +0.01% (256.00B)
StaticClassLiteral<'db>::try_mro_::interned_arguments 1.41MB 1.41MB +0.01% (216.00B)
StaticClassLiteral<'db>::is_typed_dict_ 621.13kB 620.96kB -0.03% (180.00B)
GenericAlias 1.18MB 1.18MB +0.01% (144.00B)
ClassType<'db>::nearest_disjoint_base_ 101.52kB 101.63kB +0.11% (116.00B)

sphinx

Name Old New Diff Outcome
infer_scope_types_impl 15.54MB 15.55MB +0.09% (13.93kB)
FunctionType<'db>::last_definition_raw_signature_ 2.04MB 2.04MB +0.09% (1.79kB)
CallableType 930.95kB 932.08kB +0.12% (1.12kB)
Specialization 1.02MB 1.02MB +0.08% (880.00B)
Type<'db>::apply_specialization_ 1.63MB 1.63MB +0.04% (676.00B)
Type<'db>::apply_specialization_::interned_arguments 1.44MB 1.44MB +0.04% (640.00B)
TupleType<'db>::to_class_type_ 159.57kB 160.14kB +0.36% (588.00B)
FunctionType<'db>::signature_ 2.26MB 2.26MB +0.02% (568.00B)
is_redundant_with_impl::interned_arguments 1.99MB 1.99MB +0.01% (264.00B)
GenericAlias 449.93kB 450.14kB +0.05% (216.00B)
StaticClassLiteral<'db>::is_typed_dict_ 183.83kB 183.66kB -0.10% (180.00B)
IntersectionType 874.85kB 875.02kB +0.02% (168.00B)
is_redundant_with_impl 1.76MB 1.76MB +0.01% (144.00B)
UnionType 1.24MB 1.24MB +0.01% (112.00B)
TypeGuardType 1.03kB 1.12kB +8.33% (88.00B)
... 3 more

flake8

Name Old New Diff Outcome
infer_scope_types_impl 999.69kB 1002.95kB +0.33% (3.26kB)
FunctionType<'db>::last_definition_raw_signature_ 77.85kB 80.73kB +3.69% (2.88kB)
CallableType 143.44kB 145.12kB +1.18% (1.69kB)
FunctionType 436.34kB 437.78kB +0.33% (1.44kB)
Type<'db>::member_lookup_with_policy_ 486.12kB 487.32kB +0.25% (1.20kB)
Type<'db>::class_member_with_policy_ 567.81kB 568.68kB +0.15% (884.00B)
FunctionType<'db>::signature_ 358.84kB 359.62kB +0.22% (800.00B)
is_redundant_with_impl 137.53kB 138.26kB +0.53% (744.00B)
cached_protocol_interface 43.71kB 44.40kB +1.58% (708.00B)
Type<'db>::try_call_dunder_get_ 374.88kB 375.43kB +0.15% (568.00B)
Type<'db>::apply_specialization_ 217.14kB 217.68kB +0.24% (544.00B)
enum_metadata 67.08kB 67.61kB +0.79% (544.00B)
Type<'db>::class_member_with_policy_::interned_arguments 306.01kB 306.52kB +0.17% (520.00B)
StaticClassLiteral<'db>::try_mro_ 334.89kB 335.36kB +0.14% (480.00B)
code_generator_of_static_class 60.79kB 61.25kB +0.75% (468.00B)
... 24 more

trio

Name Old New Diff Outcome
infer_scope_types_impl 4.76MB 4.76MB +0.16% (7.93kB)
check_file_impl 1.93MB 1.93MB +0.05% (987.00B)
enum_metadata 243.22kB 242.53kB -0.28% (708.00B)
infer_expression_types_impl 6.08MB 6.08MB -0.00% (228.00B)
TupleType<'db>::to_class_type_ 50.93kB 51.14kB +0.41% (212.00B)
StaticClassLiteral<'db>::is_typed_dict_ 67.30kB 67.12kB -0.26% (180.00B)
cached_protocol_interface 130.90kB 130.73kB -0.13% (168.00B)
is_redundant_with_impl 464.16kB 464.27kB +0.03% (120.00B)
Specialization 472.94kB 473.05kB +0.02% (112.00B)
infer_definition_types 7.52MB 7.52MB +0.00% (84.00B)
GenericAlias 200.11kB 200.18kB +0.04% (72.00B)

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Mar 7, 2026
@Glyphack Glyphack force-pushed the shaygan-yield-type branch 6 times, most recently from 7130978 to 893d465 Compare March 9, 2026 20:18
@Glyphack Glyphack marked this pull request as ready for review March 9, 2026 20:25
@carljm carljm removed their request for review March 9, 2026 21:11
@Glyphack Glyphack force-pushed the shaygan-yield-type branch from ef14f4b to 1debc29 Compare March 9, 2026 21:15
@sharkdp sharkdp closed this Mar 17, 2026
@sharkdp sharkdp reopened this Mar 17, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 17, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-yield 79 0 0
invalid-await 0 40 0
unused-type-ignore-comment 0 10 0
invalid-assignment 0 0 2
invalid-argument-type 1 0 0
invalid-return-type 0 1 0
Total 80 51 2

Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.

Raw diff (91 changes)
Expression (https://github.com/cognitedata/Expression)
+ README.py:358:20 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ README.py:382:20 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ README.py:385:20 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ README.py:455:20 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ README.py:456:20 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:43:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:107:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:123:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:136:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:159:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:218:9 [error] [invalid-yield] Yield type `None` does not match annotated yield type `Option[int]`
+ tests/test_option_builder.py:269:32 [error] [invalid-yield] Send type `None` does not match annotated send type `str`
+ tests/test_option_builder.py:285:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_option_builder.py:288:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:42:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:106:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:122:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:139:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:162:29 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:221:9 [error] [invalid-yield] Yield type `None` does not match annotated yield type `Result[int, str]`
+ tests/test_result_builder.py:277:32 [error] [invalid-yield] Send type `None` does not match annotated send type `str`
+ tests/test_result_builder.py:293:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_result_builder.py:296:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_seq_builder.py:186:9 [error] [invalid-yield] Yield type `None` does not match annotated yield type `Iterable[int]`
+ expression/core/option.py:308:15 [error] [invalid-yield] Yield type `None` does not match annotated yield type `_TSourceOut@Option`
+ expression/core/result.py:267:15 [error] [invalid-yield] Yield type `None` does not match annotated yield type `_TSourceOut@Result`
+ tests/test_catch.py:72:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_catch.py:83:24 [error] [invalid-yield] Send type `None` does not match annotated send type `int`
+ tests/test_catch.py:99:24 [error] [invalid-yield] Send type `None` does not match annotated send type `str`

PyGithub (https://github.com/PyGithub/PyGithub)
- github/PaginatedList.py:125:47 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/clients.py:2720:13 [error] [invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `@Todo` on object of type `dict[Path, ModuleType]`
+ tanjun/clients.py:2720:13 [error] [invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `ModuleType` on object of type `dict[Path, ModuleType]`
- tanjun/clients.py:2720:13 [error] [invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `@Todo` on object of type `dict[str, ModuleType]`
+ tanjun/clients.py:2720:13 [error] [invalid-assignment] Invalid subscript assignment with key of type `str | Path` and value of type `ModuleType` on object of type `dict[str, ModuleType]`

aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/cookiejar.py:592:25 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/internal/mappings.py:240:28 [error] [invalid-yield] Yield type `tuple[str, object]` does not match annotated yield type `tuple[str, V@TypedBox]`

bidict (https://github.com/jab/bidict)
+ bidict/_iter.py:26:20 [error] [invalid-yield] Yield type `tuple[object, object]` does not match annotated yield type `tuple[KT@iteritems, VT@iteritems]`
+ bidict/_iter.py:28:20 [error] [invalid-yield] Yield type `tuple[object, object]` does not match annotated yield type `tuple[KT@iteritems, VT@iteritems]`

black (https://github.com/psf/black)
+ src/black/trans.py:502:19 [error] [invalid-yield] Yield type `Ok[object]` does not match annotated yield type `Ok[Line] | Err[CannotTransform]`

boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:602:19 [error] [invalid-yield] Yield type `object` does not match annotated yield type `T@iter_underlying`

core (https://github.com/home-assistant/core)
+ homeassistant/components/backup/manager.py:1840:35 [error] [invalid-yield] Yield type `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | (bytes & ~AlwaysFalsy)` does not match annotated yield type `bytes`
+ homeassistant/components/backup/manager.py:1990:27 [error] [invalid-yield] Yield type `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | (bytes & ~AlwaysFalsy)` does not match annotated yield type `bytes`

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/process.py:315:23 [error] [invalid-yield] Yield type `(MutableMapping[str, None | int | str | ... omitted 3 union elements] & Top[dict[Unknown, Unknown]]) | (MutableSequence[MutableMapping[str, None | int | str | ... omitted 3 union elements]] & Top[dict[Unknown, Unknown]])` does not match annotated yield type `MutableMapping[str, None | int | str | ... omitted 3 union elements]`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ tests/debugging/mocking.py:199:15 [error] [invalid-yield] Yield type `Debugger` does not match annotated yield type `TestDebugger`
+ tests/debugging/mocking.py:234:15 [error] [invalid-yield] Yield type `Unknown | SignalUploader | None` does not match annotated yield type `MockSignalUploader`

discord.py (https://github.com/Rapptz/discord.py)
+ discord/abc.py:1821:23 [error] [invalid-yield] Yield type `Message` does not match annotated yield type `PinnedMessage`
+ discord/ext/commands/cog.py:461:32 [error] [invalid-yield] Yield type `Command[Never, (...), Any]` does not match annotated yield type `Command[Self@walk_commands, (...), Any]`
+ discord/ext/commands/core.py:1455:28 [error] [invalid-yield] Yield type `Command[Never, (...), Any]` does not match annotated yield type `Command[CogT@GroupMixin, (...), Any]`
+ discord/utils.py:1046:19 [error] [invalid-yield] Yield type `list[object]` does not match annotated yield type `list[T@_chunk]`

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/porcelain/__init__.py:5047:23 [error] [invalid-yield] Yield type `str | bytes | PathLike[str]` does not match annotated yield type `str`

httpx-caching (https://github.com/johtso/httpx-caching)
- httpx_caching/_policy.py:216:76 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive
- httpx_caching/_policy.py:233:60 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ httpx_caching/_policy.py:126:46 [error] [invalid-yield] Send type `tuple[Response, dict[Unknown, Unknown]]` does not match annotated send type `Response`

ibis (https://github.com/ibis-project/ibis)
+ ibis/expr/rewrites.py:183:23 [error] [invalid-yield] Yield type `ibis.expr.types.generic.Value` does not match annotated yield type `ibis.expr.operations.core.Value[Unknown, Any]`
+ ibis/util.py:703:15 [error] [invalid-yield] Yield type `type[T@get_subclasses]` does not match annotated yield type `type[S@get_subclasses]`

kopf (https://github.com/nolar/kopf)
+ kopf/_cogs/structs/dicts.py:261:28 [error] [invalid-yield] Send type `Never` does not match annotated send type `None`

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/plugins/openlibrary/lists.py:125:23 [error] [invalid-yield] Yield type `dict[str, dict[str, ThingReferenceDict | str | AnnotatedSeedDict]]` does not match annotated yield type `AnnotatedSeedDict`
+ openlibrary/plugins/openlibrary/lists.py:125:41 [error] [invalid-argument-type] Invalid argument to key "key" with declared type `str` on TypedDict `ThingReferenceDict`: value of type `(ThingReferenceDict & ~Top[dict[Unknown, Unknown]]) | str | (AnnotatedSeedDict & ~Top[dict[Unknown, Unknown]])`

pandas (https://github.com/pandas-dev/pandas)
- pandas/io/formats/format.py:1068:20 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/grammar.py:399:13 [error] [invalid-yield] Yield type `None` does not match annotated yield type `tuple[str, str]`

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_compat.py:47:13 [error] [invalid-yield] Yield type `None` does not match annotated yield type `str | Interpolation`

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/macho.py:406:19 [error] [invalid-yield] Yield type `bytearray` does not match annotated yield type `bytes`
+ pwndbg/aglib/macho.py:578:19 [error] [invalid-yield] Yield type `tuple[bytearray, int]` does not match annotated yield type `tuple[bytes, int]`
+ pwndbg/commands/rop.py:197:15 [error] [invalid-yield] Yield type `tuple[str | None, None]` does not match annotated yield type `tuple[str, Page | None]`

pylint (https://github.com/pycqa/pylint)
+ pylint/checkers/utils.py:2055:28 [error] [invalid-yield] Send type `Never` does not match annotated send type `None`
+ pylint/checkers/utils.py:2067:28 [error] [invalid-yield] Send type `Never` does not match annotated send type `None`
+ pylint/checkers/utils.py:2070:28 [error] [invalid-yield] Send type `Never` does not match annotated send type `None`

rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/aggregator.py:1282:55 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/engine/core.py:134:50 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

scipy (https://github.com/scipy/scipy)
- subprojects/array_api_extra/tests/conftest.py:124:32 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/asyncgen.py:19:19 [error] [invalid-yield] Yield type `object` does not match annotated yield type `_T@as_async_generator`

starlette (https://github.com/encode/starlette)
+ tests/test_routing.py:697:9 [error] [invalid-yield] Yield type `None` does not match annotated yield type `Never`

static-frame (https://github.com/static-frame/static-frame)
- static_frame/test/integration/test_field_stats.py:61:78 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/bus_mapping.py:45:20 [error] [invalid-yield] Yield type `Unknown | tuple[Hashable, @Todo]` does not match annotated yield type `tuple[TVKeys@BusMappingItemsView, @Todo]`
+ static_frame/core/memory_measure.py:241:23 [error] [invalid-yield] Yield type `tuple[str, list[Unknown]]` does not match annotated yield type `tuple[tuple[str, ...], list[int]]`
- static_frame/core/quilt.py:859:45 [warning] [unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ static_frame/core/type_blocks.py:882:19 [error] [invalid-yield] Yield type `tuple[None | Unknown, int | Unknown]` does not match annotated yield type `tuple[dtype[Any], int]`
+ static_frame/core/type_blocks.py:1286:24 [error] [invalid-yield] Yield type `tuple[Hashable, ndarray[Any, Any], TypeBlocks | ndarray[Any, Any]]` does not match annotated yield type `tuple[ndarray[Any, Any], ndarray[Any, Any] | slice[Any, Any, Any], TypeBlocks]`
+ static_frame/core/type_blocks.py:1307:24 [error] [invalid-yield] Yield type `tuple[Hashable, slice[Any, Any, Any], TypeBlocks | ndarray[Any, Any]]` does not match annotated yield type `tuple[Hashable, ndarray[Any, Any] | slice[Any, Any, Any], ndarray[Any, Any]]`
+ static_frame/core/type_blocks.py:1316:24 [error] [invalid-yield] Yield type `tuple[Hashable, ndarray[Any, Any], TypeBlocks | ndarray[Any, Any]]` does not match annotated yield type `tuple[Hashable, ndarray[Any, Any] | slice[Any, Any, Any], ndarray[Any, Any]]`
+ static_frame/core/type_blocks.py:2927:27 [error] [invalid-yield] Yield type `Sequence[Any] | @Todo` does not match annotated yield type `tuple[Any, ...]`
+ static_frame/core/type_blocks.py:2930:27 [error] [invalid-yield] Yield type `Sequence[Any] | @Todo` does not match annotated yield type `tuple[Any, ...]`
+ static_frame/core/type_blocks.py:2941:23 [error] [invalid-yield] Yield type `Sequence[Any] | @Todo` does not match annotated yield type `tuple[Any, ...]`
+ static_frame/core/type_blocks.py:1284:24 [error] [invalid-yield] Yield type `tuple[Hashable, slice[Any, Any, Any], TypeBlocks | ndarray[Any, Any]]` does not match annotated yield type `tuple[ndarray[Any, Any], ndarray[Any, Any] | slice[Any, Any, Any], TypeBlocks]`
+ static_frame/core/type_blocks.py:2989:23 [error] [invalid-yield] Yield type `Sequence[Any] | @Todo` does not match annotated yield type `tuple[Any, ...]`
+ static_frame/test/unit/test_frame.py:6641:23 [error] [invalid-yield] Yield type `tuple[int, ndarray[tuple[Any, ...], dtype[Any]]]` does not match annotated yield type `tuple[int, tuple[int, int]]`
+ static_frame/test/unit/test_store_zip.py:310:24 [error] [invalid-yield] Yield type `tuple[Hashable, Frame]` does not match annotated yield type `tuple[str, Frame]`

vision (https://github.com/pytorch/vision)
+ test/datasets_utils.py:385:19 [error] [invalid-yield] Yield type `tuple[Unknown, Unknown | None]` does not match annotated yield type `tuple[VisionDataset, dict[str, Any]]`

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/structures.py:33:20 [error] [invalid-yield] Yield type `tuple[object, object]` does not match annotated yield type `tuple[K@iter_multi_items, V@iter_multi_items]`
+ src/werkzeug/datastructures/structures.py:38:27 [error] [invalid-yield] Yield type `tuple[object, object]` does not match annotated yield type `tuple[K@iter_multi_items, V@iter_multi_items]`
+ src/werkzeug/datastructures/structures.py:40:23 [error] [invalid-yield] Yield type `tuple[object, ~Top[list[Unknown]] & ~tuple[object, ...] & ~Top[set[Unknown]]]` does not match annotated yield type `tuple[K@iter_multi_items, V@iter_multi_items]`
+ src/werkzeug/test.py:167:20 [error] [invalid-yield] Send type `Never` does not match annotated send type `None`

xarray (https://github.com/pydata/xarray)
+ xarray/core/dataset.py:2675:23 [error] [invalid-yield] Yield type `tuple[Hashable, _arrayfunction[Any, Any] | _arrayapi[Any, Any] | ndarray[tuple[Any, ...], dtype[Unknown]] | Unknown]` does not match annotated yield type `tuple[Hashable, int | slice[Any, Any, Any] | ndarray[tuple[Any, ...], dtype[Any]] | Variable]`

Full report with detailed diff (timing results)

@Glyphack Glyphack force-pushed the shaygan-yield-type branch 2 times, most recently from f07b1f1 to 72a0a9e Compare March 17, 2026 16:58
@Glyphack
Copy link
Copy Markdown
Contributor Author

I just rebased the branch as I was going to work on the remaining failing yield test case in conformance tests(I move that in a separate PR to not change the ecosystem results) for return type checking.

Copy link
Copy Markdown
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution and sorry for not getting back to you earlier. It looks good from a first scan, I plan to fully review it tomorrow.

Just one question upfront.

Copy link
Copy Markdown
Contributor

@sharkdp sharkdp 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. I'm pushing a change that should remove some of the ecosystem false positives.

@sharkdp sharkdp force-pushed the shaygan-yield-type branch from f6040b1 to 1c2c6bd Compare March 20, 2026 13:00
@sharkdp sharkdp force-pushed the shaygan-yield-type branch from 1c2c6bd to 497a0a7 Compare March 20, 2026 14:31
@sharkdp sharkdp requested a review from MichaReiser as a code owner March 20, 2026 14:31
Copy link
Copy Markdown
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@sharkdp sharkdp merged commit f3b61a0 into astral-sh:main Mar 20, 2026
49 checks passed
@Glyphack Glyphack deleted the shaygan-yield-type branch March 20, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants