-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-32717: Document PEP 560 #6726
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
Conversation
@ned-deily I am not sure about 3.7 policies now about documentation. This is a purely documentation PR, is it OK to backport this to Python 3.7 between now and final release? |
Bug fixes appropriate for a maintenance release and doc updates are ok for 370rc1. |
OK, thanks! |
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.
Would be nice to add an index entry for __mro_entries__
.
Doc/library/types.rst
Outdated
|
||
Resolve MRO entries dynamically as specified by :pep:`560`. | ||
|
||
This function looks for items in ``bases`` that are not instances of |
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.
*bases*
Parameters are marked up so.
Doc/library/types.rst
Outdated
Resolve MRO entries dynamically as specified by :pep:`560`. | ||
|
||
This function looks for items in ``bases`` that are not instances of | ||
:func:`type`, and returns a tuple where each such object that has |
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.
:class:`type`
?
:func:
adds ()
.
Doc/library/types.rst
Outdated
|
||
This function looks for items in ``bases`` that are not instances of | ||
:func:`type`, and returns a tuple where each such object that has | ||
an ``__mro_entries__`` method is replaced with an unpacked result of |
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 would write :meth:`__mro_entries__`
.
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.
This actually makes visually inconsistent with how __prepare__
appears here and elsewhere, so I would keep it as is.
Doc/reference/datamodel.rst
Outdated
.. method:: class.__class_getitem__(cls, args) | ||
|
||
Return an object representing the specialization of a generic class | ||
by type arguments found in ``args`` 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.
*args*
I would rename args
to key
. It is not always a tuple.
Doc/reference/datamodel.rst
Outdated
One can implement the generic class syntax as specified by :pep:`484` | ||
(for example ``List[int]``) by defining a special method | ||
|
||
.. method:: class.__class_getitem__(cls, args) |
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.
object
, not class
.
I would use classmethod
as for __init_subclass__
.
Doc/reference/datamodel.rst
Outdated
This method is looked up on the class object itself, and when defined in | ||
the class body, this method is implicitly a class method. | ||
|
||
.. note:: This mechanism is primarily reserved for use with static type |
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.
Does it work? This style looks uncommon. I would start the note from the new line.
Or better remove the note
directive at all. It attracts much attention, but it doesn't look too important.
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.
It actually worked, but I would just remove it.
Doc/whatsnew/3.7.rst
Outdated
Initially :pep:`484` was designed in such way that it would not introduce *any* | ||
changes to the core CPython interpreter. Now type hints and the :mod:`typing` | ||
module are extensively used by the community, so this restriction is removed. | ||
The PEP introduces two special methods ``__class_getitem__`` and |
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.
:meth:`__class_getitem__`
More links is good in What's New.
@serhiy-storchaka Thanks for review! I now addressed your comments, please take a look again. |
Thanks @ilevkivskyi for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
(cherry picked from commit bd5f965) Co-authored-by: Ivan Levkivskyi <[email protected]>
GH-6729 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit bd5f965) Co-authored-by: Ivan Levkivskyi <[email protected]>
I am sorry for a delay! Finally, here are the docs.
Attn: @gvanrossum
https://bugs.python.org/issue32717