FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-109961: Docs: Fix incorrect rendering of `__replace__` in `copy.rst` by sobolevn · Pull Request #109968 · python/cpython · GitHub

Repository navigation

gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst - #109968

Merged
hugovk merged 3 commits into
python:mainfrom
sobolevn:issue-109961
Sep 28, 2023
Merged

hugovk merged 3 commits into
python:mainfrom
sobolevn:issue-109961

Conversation

sobolevn commented Sep 27, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

This is how it looks now:

I've also added __copy__ and __deepcopy__ definitions, so they can be referenced.

Refs #101100


📚 Documentation preview 📚: https://cpython-previews--109968.org.readthedocs.build/

sobolevn requested review from hugovk and serhiy-storchaka and removed request for serhiy-storchaka September 27, 2023 13:27
AlexWaygood changed the title gh-109961: Fix incorrect rendering of __replace__ in library/copyrst gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst Sep 27, 2023

Copy link
Copy Markdown
Member

I think we could consider adding these to the datamodel and moving out of copy, I don't know what you'd think?

A

AA-Turner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Sep 27, 2023

Copy link
Copy Markdown
Member

The markup changes for copy/deepcopy should be backported; replace should be left out.

A

AA-Turner added the docs Documentation in the Doc dir label Sep 27, 2023

AlexWaygood commented Sep 27, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

I think we could consider adding these to the datamodel and moving out of copy, I don't know what you'd think?

Keeping these methods in the copy docs isn't without precedent: __fspath__ is documented in the os docs; __subclasshook__ is documented in the abc docs. I think there's an argument for keeping them close to the functions they're relevant to.

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

Comment thread Doc/library/copy.rst
The memo dictionary should be treated as an opaque object.
special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`.

.. method:: object.__copy__(self)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But please keep :noindex:. There are already entries for __replace__ etc, and duplicates that refer to the same target are confusing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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__

sobolevn Sep 27, 2023 •
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

With two indexes we have:

They link to:

  • copy.html#copy.object.__replace__
  • copy.html#index-2

Do we need the index directive itself now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You could consider :noindexentry:?

A

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It generated just one link in index.html: copy.html#index-2
No warnings 👍

Thanks, TIL about noindexentry :)

Comment thread Doc/library/copy.rst
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__`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

hugovk merged commit 0baf726 into python:main Sep 28, 2023

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

Copy link
Copy Markdown
Contributor

Sorry, @sobolevn and @hugovk, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 0baf72696e79191241a2d5cfdfd7e6135115f7b2 3.12

Copy link
Copy Markdown
Contributor

Sorry, @sobolevn and @hugovk, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 0baf72696e79191241a2d5cfdfd7e6135115f7b2 3.11

hugovk commented Sep 28, 2023

Copy link
Copy Markdown
Member

@sobolevn Please could you do the backports? Thank you!

Copy link
Copy Markdown
Member

I think this needs a follow-up PR for Serhiy's note: #109968 (comment)

A

Copy link
Copy Markdown
Member Author

Will do both :)

csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 29, 2023
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
ZeroIntensity removed the needs backport to 3.11 only security fixes label Feb 17, 2025

hugovk commented Feb 20, 2025

Copy link
Copy Markdown
Member

Will do both :)

@sobolevn Still needed? If not, let's remove the backport label.

hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 6, 2025
…` in `copy.rst` (pythonGH-109968)

(cherry picked from commit 0baf726)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

bedevere-app Bot commented Mar 6, 2025

Copy link
Copy Markdown

GH-130909 is a backport of this pull request to the 3.12 branch.

bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 6, 2025
hugovk added a commit that referenced this pull request Mar 17, 2025
…copy.rst` (GH-109968) (#130909)

(cherry picked from commit 0baf726)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL