Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typing.py get_args and get_origin should support PEP 604 and 612 #86906

Closed
Fidget-Spinner opened this issue Dec 25, 2020 · 4 comments
Closed
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Fidget-Spinner
Copy link
Member

BPO 42740
Nosy @gvanrossum, @ilevkivskyi, @miss-islington, @Fidget-Spinner
PRs
  • bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin #23942
  • bpo-42740: Fix get_args for PEP 585 collections.abc.Callable #23963
  • [3.9] bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963) #23977
  • 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-12-29.02:29:46.598>
    created_at = <Date 2020-12-25.15:19:22.201>
    labels = ['type-bug', 'library', '3.9', '3.10']
    title = 'typing.py get_args and get_origin should support PEP 604 and 612'
    updated_at = <Date 2020-12-29.02:29:46.597>
    user = 'https://github.com/Fidget-Spinner'

    bugs.python.org fields:

    activity = <Date 2020-12-29.02:29:46.597>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-29.02:29:46.598>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2020-12-25.15:19:22.201>
    creator = 'kj'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42740
    keywords = ['patch']
    message_count = 4.0
    messages = ['383747', '383924', '383925', '383945']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'levkivskyi', 'miss-islington', 'kj']
    pr_nums = ['23942', '23963', '23977']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42740'
    versions = ['Python 3.9', 'Python 3.10']

    @Fidget-Spinner
    Copy link
    Member Author

    Currently get_args doesn't work for PEP-604 Union:

    >> get_args(int | str)

    or new Callables with PEP-612:

    >>> P = ParamSpec('P)
    >>> get_args(Callable[P, int])
    ([~P], <class 'int'>)

    get_origin doesn't work with PEP-604 Unions:

    >> get_origin(int | str)

    PS: the fix has to be backported partly to 3.9. Because get_args doesn't handle collections.abc.Callable either.

    @Fidget-Spinner Fidget-Spinner added 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 25, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset 4140f10 by Ken Jin in branch 'master':
    bpo-42740: Fix get_args for PEP-585 collections.abc.Callable (GH-23963)
    4140f10

    @miss-islington
    Copy link
    Contributor

    New changeset 03e571f by Miss Islington (bot) in branch '3.9':
    bpo-42740: Fix get_args for PEP-585 collections.abc.Callable (GH-23963)
    03e571f

    @gvanrossum
    Copy link
    Member

    New changeset efb1f09 by Ken Jin in branch 'master':
    bpo-42740: Support PEP-604, 612 for typing.py get_args and get_origin (GH-23942)
    efb1f09

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants