Repository navigation
gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst - #109968
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 |
| 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.
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.
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.
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.
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.
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 <mail@sobolevn.me>
|
GH-130909 is a backport of this pull request to the 3.12 branch. |

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/