-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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-42198: Document __new__ for types.GenericAlias #23039
Conversation
``t_origin`` should be a non-parameterized generic class, such as ``list``, | ||
``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of | ||
length 1) of types which parameterize ``t_origin``:: |
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.
The argument types are not checked, e.g. types.GenericAlias(1, 2)
returns something with __origin__ == 1
and __args__ == (2,)
. But I'm not sure we ought to document that -- perhaps it's better to leave that out (even if I can see some odd use cases for 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.
Yeah I noticed that you can produce things like int[str]
as well (or anything for that matter). IMO, it would be best to document the current expected/common/intended use case for it. In the future if GenericAlias
is used for more functionality, someone can just document that.
Thanks @Fidget-Spinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry @Fidget-Spinner, I had trouble checking out the |
KJ, I don’t know why, but again this failed to backport cleanly... |
GH-23061 is a backport of this pull request to the 3.9 branch. |
From the past two cherry picks, it seems like the 3.10 docs have stuff only in 3.10 immediately surrounding the |
https://bugs.python.org/issue42198
Automerge-Triggered-By: GH:gvanrossum