Skip to content

Improve representation of TypedDicts #3590

Description

@JukkaL

reveal_type() used with a TypedDict generates a long output that is quite different from the current syntax for defining a TypedDict. Example:

TypedDict(x=builtins.int, y=builtins.int, z=builtins.int, _fallback=typing.Mapping[builtins.str, builtins.int])

Not sure what's the best course action. Some ideas:

  • Drop fallback if it's a Mapping, since it's at least mostly redundant.
  • Use {'x': builtins.int, ...} instead of x=builtins.int, ....
  • Support the syntax TypedDict('Name', x=int, ...) for defining a TypedDict, so that the supported syntax is closer to reveal_type.
  • Do something about required/non-required keys. The best approach probably depends on other choices.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions