You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid error type in math.factorial sphinx docs/docstring #133904
Documentation says: Raises ValueError if n is not integral or is negative.
Docstring: Raise a ValueError if x is negative or non-integral.
State of art:
>>> math.factorial(1.0)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
math.factorial(1.0)
~~~~~~~~~~~~~~^^^^^
TypeError: 'float' object cannot be interpreted as an integer
>>> math.factorial(-1.0)
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
math.factorial(-1.0)
~~~~~~~~~~~~~~^^^^^^
TypeError: 'float' object cannot be interpreted as an integer
>>> math.factorial(-1)
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
math.factorial(-1)
~~~~~~~~~~~~~~^^^^
ValueError: factorial() not defined for negative values
Documentation should be fixed to state, that TypeError is raised for non-integral arguments.
Or just omit description of exceptions and reduce docs to: "Return factorial of the nonnegative integer n."
Activity
StanFromIreland commentedon May 11, 2025
+1, clear as to what n should be, error should be expected otherwise.
mkaraev commentedon May 11, 2025
I opened PR
#133907
StanFromIreland commentedon May 11, 2025
The pr is automatically linked, you do not need to comment it.
Fix incorrect error type in math.factorial documentation (pythonGH-13…
gh-133904: Fix `math.factorial` documentation (#133907)
pythongh-133904: Fix `math.factorial` documentation (pythonGH-133907)
[3.13] gh-133904: Fix `math.factorial` documentation (GH-133907) (#13…
[3.14] gh-133904: Fix `math.factorial` documentation (GH-133907) (#13…
skirpichev commentedon May 12, 2025
I think, all merged.
@mkaraev, congratulations!
mkaraev commentedon May 12, 2025
@skirpichev @sobolevn thank you for your help :)
pythongh-133904: Fix `math.factorial` documentation (python#133907)
pythongh-133904: Fix `math.factorial` documentation (python#133907)