This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add ability to annotate types.Union
Type: enhancement Stage: resolved
Components: Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ROpdebee, gvanrossum, kj, lukasz.langa, miss-islington, serhiy.storchaka, uriyyo
Priority: normal Keywords: patch

Created on 2021-07-17 10:33 by uriyyo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27214 merged uriyyo, 2021-07-17 10:34
PR 27461 merged miss-islington, 2021-07-29 19:46
Messages (5)
msg397720 - (view) Author: Yurii Karabas (uriyyo) * (Python triager) Date: 2021-07-17 10:33
It was discussed at https://bugs.python.org/issue44490
msg397816 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-07-19 17:03
Nosied over people from issue44490. 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__'?
```
msg398512 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-29 19:44
New changeset 8182c8329c709f42218a8a17d81639ece5b7b627 by Yurii Karabas in branch 'main':
bpo-44662: Add ability to annotate types.Union (#27214)
https://github.com/python/cpython/commit/8182c8329c709f42218a8a17d81639ece5b7b627
msg398531 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-30 09:32
New changeset 472997659b9c73089cdc22bd7eded6f6fdcffdfe by Miss Islington (bot) in branch '3.10':
bpo-44662: Add ability to annotate types.Union (GH-27214) (GH-27461)
https://github.com/python/cpython/commit/472997659b9c73089cdc22bd7eded6f6fdcffdfe
msg398532 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-30 09:33
Thanks, Yurii! ✨ 🍰 ✨
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88828
2021-07-30 09:33:17lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg398532

stage: patch review -> resolved
2021-07-30 09:32:03lukasz.langasetmessages: + msg398531
2021-07-29 19:46:19miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25984
2021-07-29 19:44:55lukasz.langasetnosy: + lukasz.langa
messages: + msg398512
2021-07-19 17:03:27kjsetnosy: + gvanrossum, serhiy.storchaka, kj, ROpdebee

messages: + msg397816
versions: + Python 3.10
2021-07-19 16:20:34uriyyosettitle: Add ability to serialise and annotate types.Union -> Add ability to annotate types.Union
2021-07-17 10:38:01uriyyosettitle: Add ability to serialise and annotated types.Union -> Add ability to serialise and annotate types.Union
2021-07-17 10:34:07uriyyosetkeywords: + patch
stage: patch review
pull_requests: + pull_request25754
2021-07-17 10:33:33uriyyocreate