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

Add ability to annotate types.Union #88828

Closed
uriyyo opened this issue Jul 17, 2021 · 5 comments
Closed

Add ability to annotate types.Union #88828

uriyyo opened this issue Jul 17, 2021 · 5 comments
Labels
3.10 only security fixes 3.11 only security fixes type-feature A feature request or enhancement

Comments

@uriyyo
Copy link
Member

uriyyo commented Jul 17, 2021

BPO 44662
Nosy @gvanrossum, @ambv, @serhiy-storchaka, @miss-islington, @uriyyo, @Fidget-Spinner, @ROpdebee
PRs
  • bpo-44662: Add ability to annotate types.Union #27214
  • [3.10] bpo-44662: Add ability to annotate types.Union (GH-27214) #27461
  • 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 2021-07-30.09:33:17.699>
    created_at = <Date 2021-07-17.10:33:33.705>
    labels = ['type-feature', '3.10', '3.11']
    title = 'Add ability to annotate types.Union'
    updated_at = <Date 2021-07-30.09:33:17.698>
    user = 'https://github.com/uriyyo'

    bugs.python.org fields:

    activity = <Date 2021-07-30.09:33:17.698>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-30.09:33:17.699>
    closer = 'lukasz.langa'
    components = []
    creation = <Date 2021-07-17.10:33:33.705>
    creator = 'uriyyo'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44662
    keywords = ['patch']
    message_count = 5.0
    messages = ['397720', '397816', '398512', '398531', '398532']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'lukasz.langa', 'serhiy.storchaka', 'miss-islington', 'uriyyo', 'kj', 'ROpdebee']
    pr_nums = ['27214', '27461']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44662'
    versions = ['Python 3.10', 'Python 3.11']

    @uriyyo
    Copy link
    Member Author

    uriyyo commented Jul 17, 2021

    It was discussed at https://bugs.python.org/issue44490

    @uriyyo uriyyo added 3.11 only security fixes type-feature A feature request or enhancement labels Jul 17, 2021
    @uriyyo uriyyo changed the title Add ability to serialise and annotated types.Union Add ability to serialise and annotate types.Union Jul 17, 2021
    @uriyyo uriyyo changed the title Add ability to serialise and annotated types.Union Add ability to serialise and annotate types.Union Jul 17, 2021
    @uriyyo uriyyo changed the title Add ability to serialise and annotate types.Union Add ability to annotate types.Union Jul 19, 2021
    @uriyyo uriyyo changed the title Add ability to serialise and annotate types.Union Add ability to annotate types.Union Jul 19, 2021
    @Fidget-Spinner
    Copy link
    Member

    Nosied over people from bpo-44490. This issue addresses msg396895:

    Thanks to Ruben for the catch. (message copied over):

    It also lacks the __module__ attribute, causing it to be unusable in PEP 593 typing.Annotated types:
    
    from typing import Annotated
    x: Annotated[int | str, 'test']
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 298, in inner
        return cached(*args, **kwds)
      File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 1594, in __class_getitem__
        return _AnnotatedAlias(origin, metadata)
      File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 1520, in __init__
        super().__init__(origin, origin)
      File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 976, in __init__
        self.__module__ = origin.__module__
    AttributeError: 'types.Union' object has no attribute '__module__'. Did you mean: '__reduce__'?
    

    @Fidget-Spinner Fidget-Spinner added 3.10 only security fixes labels Jul 19, 2021
    @ambv
    Copy link
    Contributor

    ambv commented Jul 29, 2021

    New changeset 8182c83 by Yurii Karabas in branch 'main':
    bpo-44662: Add ability to annotate types.Union (bpo-27214)
    8182c83

    @ambv
    Copy link
    Contributor

    ambv commented Jul 30, 2021

    New changeset 4729976 by Miss Islington (bot) in branch '3.10':
    bpo-44662: Add ability to annotate types.Union (GH-27214) (GH-27461)
    4729976

    @ambv
    Copy link
    Contributor

    ambv commented Jul 30, 2021

    Thanks, Yurii! ✨ 🍰 ✨

    @ambv ambv closed this as completed Jul 30, 2021
    @ambv ambv closed this as completed Jul 30, 2021
    @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.10 only security fixes 3.11 only security fixes type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants