-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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-42317: Improve docs of typing.get_args concerning Union #23254
Conversation
Doc/library/typing.rst
Outdated
@@ -1706,6 +1706,8 @@ Introspection helpers | |||
For a typing object of the form ``X[Y, Z, ...]`` these functions return | |||
``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for a builtin or | |||
:mod:`collections` class, it gets normalized to the original class. | |||
If ``X`` is a :class:`Union`, the order of ``(Y, Z, ...)`` may be different |
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.
If ``X`` is a :class:`Union`, the order of ``(Y, Z, ...)`` may be different | |
If ``X`` is a :class:`Union` contained in another generic type, the order of ``(Y, Z, ...)`` may be different |
I don't really like the current proposed change because it's too broad, it may cause users to worry that all nested types are affected, when in reality it's only Union. Instead of:
Guido's change seems a lot more apt:
A quick search through the typing code tells me that only the |
It's as broad as the promise of type caching goes, so I don't think it's too broad. But I agree that it's broader than necessary since indeed, at the moment, it requires a
(Though I don't see why the two would be unequal; but that's a different concern)
So I just revert back to Guido's version? |
Wow good catch, that looks like it may be a bug.
Maybe a combination of both yours and Guido's wording:
Btw, thank you for 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.
Thanks, LG!
Thanks @Dominik1123 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
GH-23307 is a backport of this pull request to the 3.9 branch. |
https://bugs.python.org/issue42317
Automerge-Triggered-By: GH:gvanrossum