Skip to content
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

gh-92417: fractions, decimal: Improve docs for alternative constructor methods #92421

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented May 7, 2022

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

I would remove the note directive at all. It attracts too much attention. Instead I would add something like "This is a limited version of the :class:`Fraction` constructor which only accepts :class:`~numbers.Integral` or :class:`float`." in plain paragraph.

Replace the method directive with classmethod for class methods.

And the same should be done for Decimal. It would be better to do all this in a single PR.

@AlexWaygood AlexWaygood marked this pull request as draft May 8, 2022
@AlexWaygood AlexWaygood changed the title gh-92417: fractions docs: remove references to Python <3.2 gh-92417: fractions, decimal: Improve docs for alternative constructor methods May 8, 2022
Doc/library/fractions.rst Outdated Show resolved Hide resolved
Doc/library/decimal.rst Outdated Show resolved Hide resolved
@serhiy-storchaka serhiy-storchaka requested a review from mdickinson May 8, 2022
@AlexWaygood AlexWaygood marked this pull request as ready for review May 8, 2022
@AlexWaygood AlexWaygood requested a review from rhettinger as a code owner May 8, 2022
Doc/library/decimal.rst Outdated Show resolved Hide resolved
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 9, 2022

It would be nice if some math people (like @mdickinson, or @rhettinger, or @tim-one, or @skrah) take a look at it.

Doc/library/decimal.rst Outdated Show resolved Hide resolved
Copy link
Member

@mdickinson mdickinson left a comment

One nitpick; otherwise, the changes look good to me.

Doc/library/decimal.rst Outdated Show resolved Hide resolved
@rhettinger rhettinger self-assigned this May 9, 2022
@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented May 9, 2022

I'll give this a thorough review when I get a chance. Off-hand, it looks like an aggressive edit.

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 9, 2022

I am not sure that they can be considered legacy methods. They are useful if you want to restrict the type of the input. I even proposed to add alternate restricted constructors for other numeric types (for example see #26827).

Copy link
Member

@mdickinson mdickinson left a comment

LGTM

@AlexWaygood
Copy link
Member Author

@AlexWaygood AlexWaygood commented May 9, 2022

I am not sure that they can be considered legacy methods. They are useful if you want to restrict the type of the input. I even proposed to add alternate restricted constructors for other numeric types (for example see #26827).

I'm happy to remove the notes I added in 8f537ea, but I'll defer to you and @mdickinson on whether that's a good idea or not :)

@mdickinson
Copy link
Member

@mdickinson mdickinson commented May 9, 2022

I am not sure that they can be considered legacy methods. They are useful if you want to restrict the type of the input.

I definitely see a case for restricting to numeric input (as opposed to str or bytes, for example), but that's not quite what from_float does, or what it was intended for. from_float is legacy in the sense that it was originally introduced to make float-to-decimal conversions possible at at time when it had been decided to make Decimal(2.3) an error. That restriction was later relaxed, making from_float largely redundant.

@mdickinson
Copy link
Member

@mdickinson mdickinson commented May 9, 2022

Off-hand, it looks like an aggressive edit.

I'm in favour of having the information about the danger of Decimal(1.2) in the documentation for the main Decimal constructor instead of in the documentation of from_float, where it's less easy to notice. The error seems to be common - it turns up repeatedly in Stack Overflow questions, for example.

@mdickinson
Copy link
Member

@mdickinson mdickinson commented May 9, 2022

I'm happy to remove the notes I added in 8f537ea

That may be simplest for this PR.

@AlexWaygood
Copy link
Member Author

@AlexWaygood AlexWaygood commented May 9, 2022

I am not sure that they can be considered legacy methods. They are useful if you want to restrict the type of the input. I even proposed to add alternate restricted constructors for other numeric types (for example see #26827).

I've reverted the addition of the notes saying that they are legacy methods (cc. @serhiy-storchaka).

Doc/library/decimal.rst Outdated Show resolved Hide resolved
Doc/library/decimal.rst Show resolved Hide resolved
Doc/library/decimal.rst Outdated Show resolved Hide resolved
Doc/library/fractions.rst Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 9, 2022

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@AlexWaygood
Copy link
Member Author

@AlexWaygood AlexWaygood commented May 10, 2022

Thanks all for the reviews! I feel like I've received slightly contradictory feedback on this, and it was certainly never my intent to make an aggressive edit, so I've reduced the PR down to a minimal diff which should hopefully be less controversial.

I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 10, 2022

Thanks for making the requested changes!

@serhiy-storchaka, @mdickinson, @rhettinger: please review the changes made to this pull request.

@mdickinson
Copy link
Member

@mdickinson mdickinson commented May 10, 2022

I feel like I've received slightly contradictory feedback on this

Agreed. Raymond's assigned this to himself, so I'll duck out at this point and leave this to you and him.

@mdickinson mdickinson removed their request for review May 10, 2022
@AlexWaygood
Copy link
Member Author

@AlexWaygood AlexWaygood commented May 18, 2022

@rhettinger, is there anything more you'd like me to do here? :)

(I don't have merge privileges; I'm only a triager.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants