Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deprecate unusual ways of creating empty TypedDicts #105570

Closed
Labels
3.13bugs and security fixesstdlibPython modules in the Lib dirtopic-typingtype-featureA feature request or enhancement
@AlexWaygood

Description

@AlexWaygood

Feature or enhancement

I propose that we deprecate the following two ways of creating emptyTypedDicts:

fromtypingimportTypedDictT=TypedDict("T")T2=TypedDict("T2",None)

Pitch

Users currently have four distinct options if they want to create an emptyTypedDict with no fields:

T=TypedDict("T")T2=TypedDict("T2",None)T3=TypedDict("T3", {})classT4(TypedDict): ...

Of these four options, onlyT3 andT4 are supported by type checkers.typing.TypedDict has been around for a while now, so ifT1 andT2 are still unsupported by type checkers, they probably never will be supported.

Deprecating, and eventually removing, the first two ways of constructing empty TypedDicts will allow us to simplify the code at runtime. It will also be less confusing for users. Every way in which the runtime and type checkers differ in behaviour is a potential point of confusion for users; in general, we should work to keep these points of difference to a minimum.

I also don't think these methods of constructing empty TypedDicts are particularly common.

Previous discussion

For very similar reasons, we previously deprecated and removed the keyword-argument syntax for creating TypedDicts. This was deprecated in 3.11, and removed in 3.13:

In retrospect, we should really have deprecated these ways of creating empty TypedDicts at the same time. But there's no way of changing that now.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesstdlibPython modules in the Lib dirtopic-typingtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp