Skip to content

Refactor typing.TypedDict #84368

Closed
Closed

Description

@serhiy-storchaka
BPO 40187
Nosy @gvanrossum, @serhiy-storchaka, @ilevkivskyi
PRs
  • bpo-40187: Refactor typing.TypedDict. #19372
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-04-08.08:05:53.116>
    created_at = <Date 2020-04-04.21:20:39.697>
    labels = ['type-feature', 'library', '3.9']
    title = 'Refactor typing.TypedDict'
    updated_at = <Date 2020-04-08.08:05:53.116>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-04-08.08:05:53.116>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-08.08:05:53.116>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2020-04-04.21:20:39.697>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40187
    keywords = ['patch']
    message_count = 3.0
    messages = ['365786', '365787', '365973']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'serhiy.storchaka', 'levkivskyi']
    pr_nums = ['19372']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40187'
    versions = ['Python 3.9']

    Activity

    1. serhiy-storchaka commented on Apr 4, 2020

      @serhiy-storchaka
      MemberAuthor

      typing.TypedDict is used in two ways.

      1. It is a callable which produces a new pseudo-subtype of dict.
      2. It can also be used as a base in the class statement for creating a new pseudo-subtype of dict.

      In both cases it is not a real class. You cannot create an instance of TypedDict or its "subclass". isinstance() and issubclass() do not work with it. Instantiating it "subclass" always returns a dict. But it is implemented as a class, and help() shows methods and data descriptors for it, which are useless.

      The proposed PR implements TypedDict as a function. It adds the __mro_entries__ method that allows to use it as a base in the class statement.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Apr 4, 2020
    3. serhiy-storchaka commented on Apr 4, 2020

      @serhiy-storchaka
      MemberAuthor

      See also bpo-40185.

    4. serhiy-storchaka commented on Apr 8, 2020

      @serhiy-storchaka
      MemberAuthor

      New changeset f228bf2 by Serhiy Storchaka in branch 'master':
      bpo-40187: Refactor typing.TypedDict. (GH-19372)
      f228bf2

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions