classification
Title: Rename types.Union to types.UnionType
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: AliyevH, Jelle Zijlstra, gvanrossum, kj, lukasz.langa, miss-islington, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-07-24 09:24 by serhiy.storchaka, last changed 2021-07-26 19:03 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27342 merged AliyevH, 2021-07-24 23:53
PR 27365 merged miss-islington, 2021-07-26 16:00
Messages (8)
msg398128 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-07-24 09:24
There are differences between typing.Union and types.Union:

* typing.Union is indexable, types.Union is not.
* types.Union is a class, typing.Union is not.

types.Union corresponds to typing._UnionGenericAlias, not typing.Union. It is confusing that typing.Union and types.Union have the same name. Note also that most classes in the types module have the "Type" suffix: FunctionType, MethodType, ModuleType, etc. I think that it would be better to rename types.Union to types.UnionType.
msg398130 - (view) Author: Hasan (AliyevH) * Date: 2021-07-24 09:33
If nobody works on it i would like to fix it
msg398177 - (view) Author: Hasan (AliyevH) * Date: 2021-07-25 00:49
should have a deprecation period and if so, how long?
msg398185 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-07-25 13:46
This is a feature added to 3.10 so if we change it before the release there is no deprecation period needed. On the other hand if we don't get it to 3.10 is going to be much difficult to rename.
msg398190 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-07-25 18:34
Agreed. I think we should do it, Serhiy’s reasoning makes sense.

We should just update the PEP and add a note that this was changed during the beta period.
msg398210 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2021-07-26 04:49
I agree that UnionType is marginally better so we should rename it. It doesn't seem worth doing if this doesn't make it in in time for 3.10, though. With the advent of PEP 604 typing.Union will hopefully become irrelevant.
msg398238 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-26 16:00
New changeset 2b8ad9e6c5f0a66e9ca2d15f85336d8a3eefefb0 by Hasan in branch 'main':
bpo-44732: Rename types.Union to types.UnionType (#27342)
https://github.com/python/cpython/commit/2b8ad9e6c5f0a66e9ca2d15f85336d8a3eefefb0
msg398247 - (view) Author: miss-islington (miss-islington) Date: 2021-07-26 19:03
New changeset 8a37e8cf45105fbb592c31ebd30501bbdea5ab81 by Miss Islington (bot) in branch '3.10':
bpo-44732: Rename types.Union to types.UnionType (GH-27342)
https://github.com/python/cpython/commit/8a37e8cf45105fbb592c31ebd30501bbdea5ab81
History
Date User Action Args
2021-07-26 19:03:15pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-07-26 19:03:07miss-islingtonsetmessages: + msg398247
2021-07-26 16:00:34miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25903
2021-07-26 16:00:30lukasz.langasetnosy: + lukasz.langa
messages: + msg398238
2021-07-26 04:49:10Jelle Zijlstrasetnosy: + Jelle Zijlstra
messages: + msg398210
2021-07-25 18:34:12gvanrossumsetmessages: + msg398190
2021-07-25 13:46:30pablogsalsetmessages: + msg398185
2021-07-25 00:49:13AliyevHsetmessages: + msg398177
2021-07-24 23:53:27AliyevHsetkeywords: + patch
stage: patch review
pull_requests: + pull_request25884
2021-07-24 09:33:46AliyevHsetnosy: + AliyevH
messages: + msg398130
2021-07-24 09:24:20serhiy.storchakacreate