-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
bpo-44732: Rename types.Union to types.UnionType #27342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not change this news entry 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about it 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, maybe we do actually want this changed as it hasn't been released yet 🤦. Sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem.
Can you please tell me X time in deprecation warning?😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey thanks 😄
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 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Lib/types.py
Outdated
@@ -2,6 +2,7 @@ | |||
Define names for built-in types that aren't directly accessible as a builtin. | |||
""" | |||
import sys | |||
import warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need import warnings
? I can not see the usage of this module at types.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No :) I forgot about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM💫
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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.
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