Skip to content

Visit functional TypedDict keyword arguments correctly - #28584

Merged
ntBre merged 1 commit into
brent/typeddict-keywordsfrom
brent/callable-typeddict-keywords
Sep 15, 2026
Merged

ntBre merged 1 commit into
brent/typeddict-keywordsfrom
brent/callable-typeddict-keywords

Conversation

@ntBre

@ntBre ntBre commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This is a follow-up to the review on #28533. We were previously visiting all of the keyword
arguments to functional TypedDict constructor calls as type definitions, in line with this usage:

>>> from typing import TypedDict
>>> Point2D = TypedDict('Point2D', x=int, y=int, label=str)
>>> Point2D.__required_keys__
frozenset({'x', 'y', 'label'})

However, this usage was actually deprecated in 3.11 and fully removed in 3.13, paving the way for
the new closed keyword added in 3.15.

This PR updates our TypedDict keyword argument traversal to visit only these legacy arguments and
the new extra_items argument as types and to visit other arguments as non-types instead.

Test Plan

New mdtests and a couple of updates to existing snapshots

Summary
--

This is a follow-up to the review on #28533. We were previously visiting all of the keyword
arguments to functional `TypedDict` constructor calls as type definitions, in line with this usage:

```pycon
>>> from typing import TypedDict
>>> Point2D = TypedDict('Point2D', x=int, y=int, label=str)
>>> Point2D.__required_keys__
frozenset({'x', 'y', 'label'})
```

However, this usage was actually deprecated in 3.11 and fully removed in 3.13, paving the way for
the new `closed` keyword added in 3.15.

This PR updates our `TypedDict` keyword argument traversal to visit only these legacy arguments and
the new `extra_items` argument as types and to visit other arguments as non-types instead.

Test Plan
--

New mdtests and a couple of updates to existing snapshots
@ntBre
ntBre added this pull request to stack #28585 September 14, 2026 18:00
@ntBre ntBre added the bug An issue describing something that isn't working, or a PR that fixes a bug label Sep 14, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

βœ… ecosystem check detected no linter changes.

Linter (preview)

βœ… ecosystem check detected no linter changes.

@ntBre
ntBre marked this pull request as ready for review September 14, 2026 18:36
@ntBre
ntBre requested a review from MichaReiser September 14, 2026 18:36
@ntBre
ntBre merged commit 9e181d4 into main Sep 15, 2026
50 checks passed
@ntBre
ntBre deleted the brent/callable-typeddict-keywords branch September 15, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants