-
-
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-46981: Remove typing._TypingEmpty #31836
bpo-46981: Remove typing._TypingEmpty #31836
Conversation
* get_args(Tuple[()]) returns now () instead of ((),). * Tuple[Unpack[Ts]][()] returns now the result equal to Tuple[()].
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.
Nice simplification! One thing I wonder about is whether this would break 3rd party frameworks that do runtime introspection of annotations? E.g. pydantic. Who can we ask?
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.
Thanks!
I don't think this will affect most runtime type checkers; at most it allows them to remove a special case. I did find a reference to _TypingEmpty
in the wild: https://github.com/CedricFR/dataenforce/blob/5dfc5f725d6a69197481061d6e6676fdb221adfd/dataenforce/__init__.py#L88. Seems like an attempt to implement their own version of Generic.
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.
All right!
I suppose there’s no consequences for typing_extensions either?
I just checked and typing-extensions uses |
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.
Nice simplification! One thing I wonder about is whether this would break 3rd party frameworks that do runtime introspection of annotations? E.g. pydantic. Who can we ask?
Searching pydantic, it seems that get_args
is rarely used. However, I will cc Samuel just to be sure. The last time we had a change in get_type_hints
re Union
, I sought his opinion too. Maybe this will help him figure things out if one of his tests breaks.
@samuelcolvin a summary of the change, for your info please:
typing.get_args(typing.Tuple[()])
now returns()
instead of((),)
.
Misc/NEWS.d/next/Library/2022-03-12-11-30-42.bpo-46981.ltWCxH.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
Go ahead and merge once tests pass! |
https://bugs.python.org/issue46981