Skip to content

Conversation

@donbarbos
Copy link
Contributor

@donbarbosdonbarbos commented Apr 1, 2025

@bedevere-appbedevere-appbot added awaiting review docs Documentation in the Doc dir skip news labels Apr 1, 2025
@donbarbosdonbarbos changed the title gh-131885: Add / for decimal.Context methods docsgh-131885: Document / for decimal.Context methodsApr 1, 2025
Copy link
Member

@skirpichevskirpichev left a comment

Choose a reason for hiding this comment

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

Note that signatures for pure-Python versions differ wrt C-coded extension:

>>> import _decimal, _pydecimal >>> help(_decimal.getcontext().plus) Help on built-in function plus: plus(x, /) method of decimal.Context instance Plus corresponds to the unary prefix plus operator in Python, but applies the context to the result. >>> help(_pydecimal.getcontext().plus) Help on method plus: plus(a) method of decimal.Context instance Plus corresponds to unary prefix plus in Python. The operation is evaluated using the same rules as add; the operation plus(a) is calculated as add('0', a) where the '0' has the same exponent as the operand. >>> ExtendedContext.plus(Decimal('1.3')) Decimal('1.3') >>> ExtendedContext.plus(Decimal('-1.3')) Decimal('-1.3') >>> ExtendedContext.plus(-1) Decimal('-1') 

If we are going to add slashes - pure-Python version should be fixed. Or vice-versa.

@donbarbos
Copy link
ContributorAuthor

donbarbos commented Apr 2, 2025

although I'm not a fan of using /, I think it will be easier to make the only positional arguments in pure-Python implementation

and I think here we will need ping more core members

@python-cla-bot

This comment was marked as resolved.

@skirpichevskirpichev self-requested a review August 13, 2025 03:02
@skirpichev
Copy link
Member

Sorry for a delay, it's look ok for me.

Would you like to fix the rest of the decimal sphinx docs in another pr?

@donbarbos
Copy link
ContributorAuthor

Would you like to fix the rest of the decimal sphinx docs in another pr?

Sorry, but I don't understand what you mean by "rest of the decimal sphinx docs". Do you mean some new functions like from_number?
If so, then it is probably really worth doing this in a separate PR so that there is still the possibility for bacports here, although maybe it is possible to make backports just more carefully and manually

@skirpichev
Copy link
Member

Sorry, but I don't understand what you mean by "rest of the decimal sphinx docs".

For example, setcontext() function:

>>> import _decimal, _pydecimal, inspect >>> inspect.signature(_decimal.setcontext) <Signature (context, /)> >>> inspect.signature(_pydecimal.setcontext) <Signature (context)>

You should also check Decimal methods.

@skirpichevskirpichev added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 13, 2025
@skirpichevskirpichev changed the title gh-131885: Document / for decimal.Context methodsgh-131885: update function signatures with / in decimal moduleAug 13, 2025
@skirpichevskirpichev self-requested a review August 13, 2025 07:09
@donbarbos
Copy link
ContributorAuthor

I also thought that there is a lot of / before arguments, but documenting it doesn't seem useful unless I'm missing something

For example, fma method has next signature: fma(self, /, other, third, context=None)

@skirpichev
Copy link
Member

Sphinx docs don't include self arguments, so we omit leading /.

Copy link
Member

@skirpichevskirpichev left a comment

Choose a reason for hiding this comment

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

Yes, I think all is fixed.

There is an odd description of the round() builtin, but it probably should be fixed separately.

@donbarbos
Copy link
ContributorAuthor

Thank you for review

@AA-TurnerAA-Turner changed the title gh-131885: update function signatures with / in decimal modulegh-131885: Use positional-only markers for the decimal moduleAug 18, 2025
@AA-TurnerAA-Turner merged commit 043f251 into python:mainAug 18, 2025
31 checks passed
@miss-islington-app
Copy link

Thanks @donbarbos for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automationgithub-project-automationbot moved this from Todo to Done in Docs PRsAug 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 18, 2025
…le (pythonGH-131990) (cherry picked from commit 043f251) Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@miss-islington-app
Copy link

Sorry, @donbarbos and @AA-Turner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 043f251154fbac9a4e66243b8cae220a284ed1c4 3.13 

@bedevere-app
Copy link

GH-137902 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14 bugs and security fixes label Aug 18, 2025
@bedevere-app
Copy link

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

@bedevere-appbedevere-appbot removed the needs backport to 3.13 bugs and security fixes label Aug 18, 2025
AA-Turner pushed a commit to AA-Turner/cpython that referenced this pull request Aug 18, 2025
…`` module (pythonGH-131990) (cherry picked from commit 043f251) Co-authored-by: Semyon Moroz <donbarbos@proton.me>
AA-Turner added a commit that referenced this pull request Aug 18, 2025
…ule (GH-131990) (#137904) Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…ule (GH-131990) (#137902) Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@donbarbos@skirpichev@AA-Turner