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

Allow using TypedDict for more precise typing of **kwds #4441

Closed
@ilevkivskyi

Description

@ilevkivskyi

There are some situations where a user wants to have more precisely typed**kwds. Current syntax only allows homogeneous**kwds:

deffun(x:int,*,**options:str)->None:    ...

However, in situations with many heterogeneous options listing all options in the signature could be verbose and will require rewriting some existing code. There is a vague idea to allowTypedDict for such situations. For example:

classOptions(TypedDict):timeout:intalternative:stron_error:Callable[[int],None]on_timeout:Callable[[],None]    ...deffun(x:int,*,**options:Options)->None:    ...

Maybe for such cases theTypedDict used should be automatically understood as defined withtotal=False. Also it is worth mentioning that this feature will allow reusing theTypedDicts in modules where several functions have same (or similar) option sets.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp