bpo-44732: Rename types.Union to types.UnionType #27342
Conversation
A plain rename from We could do that in import warnings
...
def __getattr__(name):
if name == 'Union':
warnings.warn('types.Union is deprecated and should be replaced with types.UnionType, it will get removed in X time', DeprecationWarning)
return UnionType
raise AttributeError(f'module {__name__} has no attribute {name}') |
@@ -1,2 +1,2 @@ | |||
Add ability to serialise ``types.Union`` objects. Patch provided by Yurii | |||
Add ability to serialise ``types.UnionType`` objects. Patch provided by Yurii |
FFY00
Jul 25, 2021
•
Member
Oh wait, maybe we do actually want this changed as it hasn't been released yet
AliyevH
Jul 25, 2021
•
Author
Contributor
no problem.
Can you please tell me X time in deprecation warning?
FFY00
Jul 25, 2021
Member
I don't know, that's up to the core devs, ask in https://bugs.python.org/issue44732 if we should have a deprecation period and if so, how long.
From what I understand, it won't be. It looks like Serhiy is planning to backport the changes to 3.10 too where Union was first introduced. Hasan, please wait a bit to see what he has to say about the PR. Thanks! |
Thanks @Fidget-Spinner . Okey let's wait |
LGTM! |
I don't see a NEWS entry in the PR but bedevere passed, am I missing something? I do think there should be a NEWS entry for this. |
The OP updated all of the existing NEWS entries that mention types.Union. That's creative, but I don't think it should be done that way. We need a new NEWS entry describing the renaming. |
As i understand, we don't touch news files and add a new one with a description of renaming types.Union to types.UnionType. |
@@ -2,6 +2,7 @@ | |||
Define names for built-in types that aren't directly accessible as a builtin. | |||
""" | |||
import sys | |||
import warnings |
uriyyo
Jul 26, 2021
Contributor
Do we need import warnings
? I can not see the usage of this module at types.py
.
LGTM |
LGTM. Thanks for your contribution! Minor note: in the future please don't force-push as it overrides commit history @AliyevH. Just commit normally, the core devs will squash and merge the PR. |
Wait, the docs here need updating too https://docs.python.org/3.10/library/types.html#types.Union. |
Got it. Thanks for support ) |
Misc/NEWS.d/next/Core and Builtins/2021-07-26-15-27-03.bpo-44732.IxObt3.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@ambv: Please replace |
GH-27365 is a backport of this pull request to the 3.10 branch. |
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 2b8ad9e) Co-authored-by: Hasan <hasan.aleeyev@gmail.com>
https://bugs.python.org/issue44732