-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst
#109968
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
__replace__ in library/copyrst__replace__ in copy.rst
|
I think we could consider adding these to the datamodel and moving out of A |
|
The markup changes for copy/deepcopy should be backported; replace should be left out. A |
Keeping these methods in the |
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.
| The memo dictionary should be treated as an opaque object. | ||
| special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`. | ||
|
|
||
| .. method:: object.__copy__(self) |
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.
But please keep :noindex:. There are already entries for __replace__ etc, and duplicates that refer to the same target are confusing.
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.
Hm, when adding noindex it starts to fail nitpick mode:
/Users/sobolev/Desktop/cpython/Doc/library/copy.rst:90: WARNING: py:meth reference target not found: object.__copy__
/Users/sobolev/Desktop/cpython/Doc/library/copy.rst:90: WARNING: py:meth reference target not found: object.__deepcopy__
/Users/sobolev/Desktop/cpython/Doc/library/copy.rst:112: WARNING: py:meth reference target not found: object.__replace__
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.
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.
You could consider :noindexentry:?
A
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 generated just one link in index.html: copy.html#index-2
No warnings 👍
Thanks, TIL about noindexentry :)
| Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`, | ||
| and only supports named tuples created by :func:`~collections.namedtuple`, | ||
| :mod:`dataclasses`, and other classes which define method :meth:`!__replace__`. | ||
| :mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`. |
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 answers a question I had: with noindexentry, can we still link to the method.
I just hope it’s not indexed as copy.object instead of builtins.object!
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.
Of course, it is copy.object. https://cpython-previews--109968.org.readthedocs.build/en/109968/library/copy.html#copy.object.__replace__
You need to add .. currentmodule:: . to make it builtin.
|
Sorry, @sobolevn and @hugovk, I could not cleanly backport this to |
|
Sorry, @sobolevn and @hugovk, I could not cleanly backport this to |
|
@sobolevn Please could you do the backports? Thank you! |
|
I think this needs a follow-up PR for Serhiy's note: #109968 (comment) A |
|
Will do both :) |
@sobolevn Still needed? If not, let's remove the backport label. |
…` in `copy.rst` (pythonGH-109968) (cherry picked from commit 0baf726) Co-authored-by: Nikita Sobolev <[email protected]>
|
GH-130909 is a backport of this pull request to the 3.12 branch. |
…copy.rst` (GH-109968) (#130909) (cherry picked from commit 0baf726) Co-authored-by: Nikita Sobolev <[email protected]>

This is how it looks now:

I've also added
__copy__and__deepcopy__definitions, so they can be referenced.Refs #101100
__replace__method incopydocs: consider addingcopy.SupportsReplace? #109961📚 Documentation preview 📚: https://cpython-previews--109968.org.readthedocs.build/