Skip to content

gh-101575: document Decimal.__round__()#101737

Merged
encukou merged 8 commits into
python:mainfrom
OTheDev:fix-issue-101575
Jun 12, 2024
Merged

gh-101575: document Decimal.__round__()#101737
encukou merged 8 commits into
python:mainfrom
OTheDev:fix-issue-101575

Conversation

@OTheDev

@OTheDev OTheDev commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

@blaisep

blaisep commented May 20, 2024

Copy link
Copy Markdown
Contributor

@encukou , is this something we could merge?
I noticed that the topic is still absent after https://docs.python.org/3/library/decimal.html#decimal.Decimal.to_integral_value

@encukou

encukou commented May 20, 2024

Copy link
Copy Markdown
Member

Thanks for the mention.
The issue here is that we don't want people to call d.__round__() directly; rather they should do round(d), as in the examples. The double-underscore method is for defining the behaviour, not using it; the docs are for users.

I'm not sure how this should be best documented; perhaps describe:: as used for set operations.

@encukou

encukou commented May 21, 2024

Copy link
Copy Markdown
Member

After talking to a few docs people, I'm pretty sure .. describe:: is the way to document this.

Comment thread Doc/library/decimal.rst Outdated

@picnixz picnixz 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.

Some wording suggestions

Comment thread Doc/library/decimal.rst Outdated
Comment thread Doc/library/decimal.rst Outdated
@encukou

encukou commented Jun 4, 2024

Copy link
Copy Markdown
Member

Looking at the rendered output, I saw the describe looks exactly like a method, which might be confusing.
I added an introduction line to separate them. Since i had the change locally to test it, I took the liberty to push the suggestion to this PR; I hope you don't mind.

Does this look good?

image

@picnixz

picnixz commented Jun 4, 2024

Copy link
Copy Markdown
Member

Generally, you'd use .. describe with a "legal" expression, e.g., .. describe:: x in S for the set membership where x and S are explained in a subsequent paragraph. In our case, I would suggest using something like:

.. describe:: round(x)
.. describe:: round(x, n)

Using a signature-based description would indeed be more confusing IMO.

@encukou

encukou commented Jun 10, 2024

Copy link
Copy Markdown
Member

Well, it's not less clear that way, so let's go with it?
image

@OTheDev

OTheDev commented Jun 11, 2024

Copy link
Copy Markdown
Contributor Author

@encukou @picnixz Thanks! Your suggestions/changes LGTM!

@encukou

encukou commented Jun 12, 2024

Copy link
Copy Markdown
Member

Thank you for the fix, @OTheDev!

@encukou encukou merged commit 7dd8c37 into python:main Jun 12, 2024
@encukou encukou added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Jun 12, 2024
@miss-islington-app

Copy link
Copy Markdown

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

@miss-islington-app

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 12, 2024
(cherry picked from commit 7dd8c37)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 12, 2024
(cherry picked from commit 7dd8c37)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Jun 12, 2024

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 12, 2024
@bedevere-app

bedevere-app Bot commented Jun 12, 2024

Copy link
Copy Markdown

GH-120395 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 Jun 12, 2024
encukou pushed a commit that referenced this pull request Jun 13, 2024
gh-101575: document Decimal.__round__() (GH-101737)
(cherry picked from commit 7dd8c37)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
encukou pushed a commit that referenced this pull request Jun 13, 2024
gh-101575: document Decimal.__round__() (GH-101737)
(cherry picked from commit 7dd8c37)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@OTheDev OTheDev deleted the fix-issue-101575 branch January 28, 2025 03:57
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.

5 participants