Skip to content

[ty] Infer dict(**TypedDict) in TypedDict context#24709

Draft
charliermarsh wants to merge 1 commit intocharlie/unpack-literalfrom
charlie/unpack-dict
Draft

[ty] Infer dict(**TypedDict) in TypedDict context#24709
charliermarsh wants to merge 1 commit intocharlie/unpack-literalfrom
charlie/unpack-dict

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Apr 19, 2026

Summary

Given, e.g., def f() -> TD: return dict(**src), we now infer dict(**src) as matching TD if src is TD, for example. So the following are accepted, whereas on main they all produce diagnostics:

from typing import TypedDict

class TD(TypedDict):
    x: int
    y: str

src = {
    "x": 1,
    "y": "foo",
}

x: TD = dict(**src)

def f() -> TD: return dict(**src)

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Apr 19, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 19, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 19, 2026

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 19, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 19, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 60 skipped benchmarks1


Comparing charlie/unpack-dict (f1cbea9) with charlie/unpack-literal (10f4c9a)

Open in CodSpeed

Footnotes

  1. 60 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.

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.

1 participant