Uh oh!
There was an error while loading. Please reload this page.
bpo-44732: Rename types.Union to types.UnionType - #27342
Conversation
There was a problem hiding this comment.
A plain rename from Union to UnionType would be a big breaking change, it should be deprecated IMO.
We could do that in types.__getattr__, by adding the following to the types module.
importwarnings
...
def__getattr__(name):
ifname=='Union':
warnings.warn('types.Union is deprecated and should be replaced with types.UnionType, it will get removed in X time', DeprecationWarning)
returnUnionTyperaiseAttributeError(f'module {__name__} has no attribute {name}')There was a problem hiding this comment.
We should not change this news entry 😛
There was a problem hiding this comment.
Oh wait, maybe we do actually want this changed as it hasn't been released yet 🤦. Sorry!
There was a problem hiding this comment.
no problem.
Can you please tell me X time in deprecation warning?😬
There was a problem hiding this comment.
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! |
AliyevH
commented
Jul 25, 2021
Thanks @Fidget-Spinner . Okey let's wait 😃 |
JelleZijlstra
commented
Jul 26, 2021
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. |
gvanrossum
commented
Jul 26, 2021
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. |
AliyevH
commented
Jul 26, 2021
As i understand, we don't touch news files and add a new one with a description of renaming types.Union to types.UnionType. |
There was a problem hiding this comment.
Do we need import warnings? I can not see the usage of this module at types.py.
Fidget-Spinner
left a comment
There was a problem hiding this comment.
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.
Fidget-Spinner
left a comment
There was a problem hiding this comment.
Wait, the docs here need updating too https://docs.python.org/3.10/library/types.html#types.Union.
AliyevH
commented
Jul 26, 2021
Got it. Thanks for support ) |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
bedevere-bot
commented
Jul 26, 2021
@ambv: Please replace |
miss-islington
commented
Jul 26, 2021
bedevere-bot
commented
Jul 26, 2021
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>
Recently, `types.Union` was renamed to `types.UnionType` on the HEAD of 3.10 (refs: python/cpython#27342). After this change, sphinx-build has been crashed because of ImportError.
Recently, `types.Union` was renamed to `types.UnionType` on the HEAD of 3.10 (refs: python/cpython#27342). After this change, sphinx-build has been crashed because of ImportError.
Recently, `types.Union` was renamed to `types.UnionType` on the HEAD of 3.10 (refs: python/cpython#27342). After this change, sphinx-build has been crashed because of ImportError.
orsenthil
commented
Aug 12, 2021
As it is already referenced in this ticket, it broke (the stable version of ) This is the trackback from sphinx-build command line. Sphinx has already fixed it in master (sphinx-doc/sphinx#9513) - The fix (aliasing to UnionType) doesn't seem great too. If we get more complaints, I think, either CPython or Sphinx project need to address this by communication / guidance. It was hard to track down this failure with the trace back. |
@orsenthil that's sad to hear :(. Is there some better place to make such changes known to the wider community? This change was discussed and agreed upon on python-dev, but that's centered around CPython so I don't think there's much visibility. It also doesn't get a What's New because it was a change during pre-release versions. |
https://bugs.python.org/issue44732