GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate keyword args syntax for TypedDict definition · Issue #90224 · python/cpython

Deprecate keyword args syntax for TypedDict definition #90224

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate keyword args syntax for TypedDict definition#90224
Copy link
Labels
3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

97littleleaf11
mannequin
opened on Dec 13, 2021
Issue body actions
BPO 46066
Nosy @gvanrossum, @JelleZijlstra, @tirkarthi, @sobolevn, @Fidget-Spinner, @AlexWaygood, @97littleleaf11
PRs
  • bpo-46066: Deprecate kwargs syntax for TypedDict definitions #31126
  • bpo-46066: catch DeprecationWarning #31428
  • 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 2022-02-17.03:26:40.796>
    created_at = <Date 2021-12-13.15:36:57.408>
    labels = ['type-bug', 'library', '3.11']
    title = 'Deprecate keyword args syntax for TypedDict definition'
    updated_at = <Date 2022-02-20.01:44:58.632>
    user = 'https://github.com/97littleleaf11'

    bugs.python.org fields:

    activity = <Date 2022-02-20.01:44:58.632>
    actor = 'JelleZijlstra'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-17.03:26:40.796>
    closer = 'JelleZijlstra'
    components = ['Library (Lib)']
    creation = <Date 2021-12-13.15:36:57.408>
    creator = '97littleleaf11'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46066
    keywords = ['patch']
    message_count = 11.0
    messages = ['408458', '408476', '408547', '412990', '413013', '413014', '413016', '413379', '413531', '413535', '413562']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'JelleZijlstra', 'xtreak', 'sobolevn', 'kj', 'AlexWaygood', '97littleleaf11']
    pr_nums = ['31126', '31428']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46066'
    versions = ['Python 3.11']

    Activity

    Next
    1. 97littleleaf11 commented on Dec 13, 2021

      @97littleleaf11
      97littleleaf11mannequin
      on Dec 13, 2021
      MannequinAuthor
      More actions

      According to the docs: https://docs.python.org/3/library/typing.html?#typing.TypedDict, there are two additional equivalent syntax for TypedDict definition.

      Point2D = TypedDict('Point2D', x=int, y=int, label=str)
      Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})

      However, the former one is quite confusing since we have the total keyword arg for TypedDict. In addition, PEP-589(https://www.python.org/dev/peps/pep-0589/#id19) doesn't have this.

      I think we could discard the definition syntax using keyword args in the doc.

    2. 97littleleaf11
      assigned
      docspython
      on Dec 13, 2021
    3. 97littleleaf11
      added
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      on Dec 13, 2021
    4. 97littleleaf11
      assigned
      docspython
      on Dec 13, 2021
    5. 97littleleaf11
      added
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      on Dec 13, 2021
    6. 97littleleaf11
      changed the title [-]Docs: TypedDict alternative definition syntax with keyword args is confusing[/-] [+][doc] TypedDict alternative definition syntax with keyword args is confusing[/+] on Dec 13, 2021
    7. 97littleleaf11
      changed the title [-]Docs: TypedDict alternative definition syntax with keyword args is confusing[/-] [+][doc] TypedDict alternative definition syntax with keyword args is confusing[/+] on Dec 13, 2021
    8. gvanrossum commented on Dec 13, 2021

      @gvanrossum
      gvanrossum
      on Dec 13, 2021
      Member
      More actions

      This is not really just a doc issue then, is it? Maybe we should just deprecate the feature?

    9. 97littleleaf11
      changed the title [-][doc] TypedDict alternative definition syntax with keyword args is confusing[/-] [+]TypedDict alternative definition syntax with keyword args is confusing[/+] on Dec 14, 2021
    10. 20 remaining items

    11. AlexWaygood
      unassigned
      docspython
      on Feb 8, 2022
    12. AlexWaygood
      added
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Feb 8, 2022
    13. AlexWaygood commented on Feb 10, 2022

      @AlexWaygood
      AlexWaygood
      on Feb 10, 2022
      Member
      More actions

      Just so that all the discussion related to this issue can be found in one place, here's a summary:

      • After opening this ticket, OP opened an issue in the python/typing repository, where the idea of deprecating this syntax received many thumbs-up reactions, and where there were no dissenting voices: TypedDict alternative definition syntax with keyword args is confusing typing#981
      • The initial impetus for this change was this mypy bug report: TypedDict using keywords causes "error: Too many arguments for TypedDict()" mypy#11555
      • Mypy's policy since January 2020 has been that it would be more trouble than it's worth to attempt to support the kwargs-based syntax: TypedDict syntax variant with keyword arguments mypy#2492 (comment)
    14. gvanrossum commented on Feb 10, 2022

      @gvanrossum
      gvanrossum
      on Feb 10, 2022
      Member
      More actions

      Go ahead and send a or to deprecate it.--
      --Guido (mobile)

    15. gvanrossum commented on Feb 10, 2022

      @gvanrossum
      gvanrossum
      on Feb 10, 2022
      Member
      More actions

      "PR"

    16. AlexWaygood commented on Feb 10, 2022

      @AlexWaygood
      AlexWaygood
      on Feb 10, 2022
      Member
      More actions

      @guido, OP already has — Jelle and I have both reviewed and approved it :)

    17. JelleZijlstra commented on Feb 17, 2022

      @JelleZijlstra
      JelleZijlstra
      on Feb 17, 2022
      Member
      More actions

      New changeset de6043e by 97littleleaf11 in branch 'main':
      bpo-46066: Deprecate kwargs syntax for TypedDict definitions (GH-31126)
      de6043e

    18. JelleZijlstra
      closed this as completedon Feb 17, 2022
    19. JelleZijlstra
      closed this as completedon Feb 17, 2022
    20. tirkarthi commented on Feb 19, 2022

      @tirkarthi
      tirkarthi
      on Feb 19, 2022
      Member
      More actions

      This change has introduced deprecation warning in tests

      PYTHONWARNINGS=always ./python -Wall -X dev -m test.test_typing     
      ........................................................................................................................................................................................................................s................................................................................................................................................................................................./home/karthikeyan/stuff/python/cpython/Lib/test/test_typing.py:4589: DeprecationWarning: The kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.
        TypedDict('Emp', _fields={'name': str, 'id': int})
      ./home/karthikeyan/stuff/python/cpython/Lib/test/test_typing.py:4602: DeprecationWarning: The kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.
        TypedDict('Hi', x=1)
      ........................................

      Ran 451 tests in 0.105s

      OK (skipped=1)

    21. JelleZijlstra commented on Feb 19, 2022

      @JelleZijlstra
      JelleZijlstra
      on Feb 19, 2022
      Member
      More actions

      Thanks, I'll send a PR.

    22. JelleZijlstra commented on Feb 20, 2022

      @JelleZijlstra
      JelleZijlstra
      on Feb 20, 2022
      Member
      More actions

      New changeset 0a8a8e7 by Jelle Zijlstra in branch 'main':
      bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
      0a8a8e7

    23. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    24. gvanrossum commented on Dec 22, 2022

      @gvanrossum
      gvanrossum
      on Dec 22, 2022
      Member
      More actions

      @labrys

      Doesn't this cause issues for keys that are valid as keys but not as identifiers?

      To the contrary, the deprecated syntax caused issues for such keys. The syntax that isn't deprecated works fine, e.g.

      Point2D = TypedDict('Point2D', {'x': int, 'y': int, '$label$': str})
      Reacted by Jelle Zijlstra
    25. labrys commented on Dec 22, 2022

      @labrys
      labrys
      on Dec 22, 2022
      More actions

      @gvanrossum Thanks for the quick response. I deleted my previous comment right after I posted it realizing I had entirely misread it as if the kwargs method was the one being retained.

    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.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.