Skip to content

gh-115684: Clarify datetime replace documentation #116519

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

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

davidlowryduda
Copy link
Contributor

@davidlowryduda davidlowryduda commented Mar 8, 2024

In #115684, HopedForLuck noted that datetime.date.replace() documentation was confusing because it looked like it would be changing immutable objects.

This documentation change specifies that the replace() methods in datetime return new objects. This uses similar wording to the documentation for datetime.combine(), which specifies that a new datetime is returned. This is also similar to wording for string.replace(), except string.replace() emphasizes that a "copy" is returned.

Resolves #115684.


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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
In python#115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves python#115684.
@Privat33r-dev
Copy link
Contributor

Thank you for your contribution, generally looks good and fixes the issue.

Thanks Privat33r-dev for the comments!
Copy link
Contributor

@Privat33r-dev Privat33r-dev left a comment

Choose a reason for hiding this comment

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

LGTM!

@davidlowryduda
Copy link
Contributor Author

Thanks! You're very quick on the reply, too.

@Privat33r-dev
Copy link
Contributor

@pganssle do you want to review? :) If not, maybe we can ping other Core members responsible for documentation?

@StanFromIreland
Copy link
Contributor

I do not see any clarifications, just rewording. What do you think @pganssle ?

@pganssle pganssle added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes and removed 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes labels Mar 23, 2025
@pganssle pganssle merged commit d2d8862 into python:main Mar 24, 2025
24 checks passed
@miss-islington-app
Copy link

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

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Mar 24, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 24, 2025
…16519)

* Clarify datetime `replace` documentation

In pythonGH-115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves pythonGH-115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------
(cherry picked from commit d2d8862)

Co-authored-by: David Lowry-Duda <[email protected]>
Co-authored-by: Paul Ganssle <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 24, 2025

GH-131676 is a backport of this pull request to the 3.13 branch.

@miss-islington-app
Copy link

Sorry, @davidlowryduda and @pganssle, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d2d886215cf694d5f3e7f0cbd76507a96bac322b 3.12

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 24, 2025
@bedevere-app
Copy link

bedevere-app bot commented Mar 24, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 24, 2025
davidlowryduda added a commit to davidlowryduda/cpython that referenced this pull request Mar 24, 2025
…honGH-116519)

* Clarify datetime `replace` documentation

In pythonGH-115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves pythonGH-115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------
(cherry picked from commit d2d8862)

Co-authored-by: David Lowry-Duda <[email protected]>
Co-authored-by: Paul Ganssle <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 24, 2025

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

diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
)

* Clarify datetime `replace` documentation

In python#115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves python#115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------

Co-authored-by: Paul Ganssle <[email protected]>
Yhg1s pushed a commit that referenced this pull request Apr 8, 2025
#131694)

* Clarify datetime `replace` documentation

In GH-115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves GH-115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------
(cherry picked from commit d2d8862)

Co-authored-by: Paul Ganssle <[email protected]>
Yhg1s pushed a commit that referenced this pull request Apr 8, 2025
#131676)

gh-115684: Clarify datetime `replace` documentation (GH-116519)

* Clarify datetime `replace` documentation

In GH-115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves GH-115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------
(cherry picked from commit d2d8862)

Co-authored-by: David Lowry-Duda <[email protected]>
Co-authored-by: Paul Ganssle <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
)

* Clarify datetime `replace` documentation

In python#115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves python#115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------

Co-authored-by: Paul Ganssle <[email protected]>
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
Status: Done
Development

Successfully merging this pull request may close these issues.

datetime.date.replace() description not clear enough
4 participants