-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
bpo-30940: fix docs for round if second arg is None #2824
Conversation
@daxlab, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @benjaminp and @rhettinger to be potential reviewers. |
Doc/library/functions.rst
Outdated
@@ -1308,8 +1308,8 @@ are always available. They are listed here in alphabetical order. | |||
equally close, rounding is done toward the even choice (so, for example, | |||
both ``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is | |||
``2``). Any integer value is valid for *ndigits* (positive, zero, or | |||
negative). The return value is an integer if called with one argument, | |||
otherwise of the same type as *number*. | |||
negative). The return value is an integer if *ndigits* is omitted or *None*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Format None
with fixed-width font instead of italic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to update the docstring too.
The signature of the function can be written as
round(number, ndigits=None)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for doing this!
Please update the docstring. And what is more correct,
(as in the first paragraph), or
(as in the second paragraph)? Or both are correct? |
|
Python/bltinmodule.c
Outdated
@@ -2086,7 +2086,7 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds) | |||
} | |||
|
|||
PyDoc_STRVAR(round_doc, | |||
"round(number[, ndigits]) -> number\n\ | |||
"round(number, ndigits=None) -> number\n\ | |||
\n\ | |||
Round a number to a given precision in decimal digits (default 0 digits).\n\ | |||
This returns an int when called with one argument, otherwise the\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"if ndigits is omitted or None"
About
versus
I think either is fine. To my eyes, the first looks a bit clearer, but also a bit more pedantic. |
@serhiy-storchaka docs updated. |
@serhiy-storchaka plz review. Also, should I send a separate PR to 3.6 branch or you can cherry-pick ? |
The current changes LGTM, but see a discussion on the tracker. Perhaps the documentation needs additional clarification. |
https://bugs.python.org/issue30940