-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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-121676: Raise a DeprecationWarning
if the Python implementation of functools.reduce
is called with a keyword args
#121677
Conversation
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.
In general, the C implementation is always used so functools.reduce() doesn't accept keyword arguments. This change fix an inconsistency when the C extension (_functools) cannot be loaded.
ISTM that adding an argument restriction to an already published function is a breaking change. |
I see how @Eclips4 would conclude that the likelihood of users running the Python version of In general, it might be tempting to treat a case like this one as a special case and relax our usual standards, but I believe it's not worth doing: we're not fixing a crippling problem, and we're not unblocking users to perform a legitimate operation. This change is a cleanup to improve consistency, it's not urgent. Moreover, the function isn't actually documented as positional-only, so we cannot claim that the current behavior of the pure Python implementation was against stated intent. Therefore, the responsible thing to do here would be to deprecate keyword argument use (through an awkward |
Thanks Łukasz for sharing your thoughts!
Actually it's documented as positional-only, but only in 3.13+ branches: I absolutely agree with you that if we can deprecate it for 3.13, that would be fine. If not, that would also be fine (should we then revert the change to the docs mentioned above?). |
No, I don't think this should be done in 3.13. The potential impact is low, but so is the benefit. It's fine to leave it documented as positional-only, but changes in behaviour (if warranted at all, and following the normal deprecation process) should go into 3.14 instead |
functools.reduce
DeprecationWarning
if the Python implementation of functools.reduce
is called with a keyword args
What's the status of this PR? I'm now confused :-( |
I'm waiting for PR #125917 to be merged, so the |
Misc/NEWS.d/next/Library/2024-07-13-13-25-31.gh-issue-121676.KDLS11.rst
Outdated
Show resolved
Hide resolved
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.
Shouldn't we also add something in the "Deprecated" section of 3.14?
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, except for missing comment on moved import.
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.
I'm suggesting renaming _warn_kwargs
to something more explicit for anyone stumbling upon the code. I'm also suggesting deleting the decorator from the module's global names.
I'm not sure if all my suggestions will pass the CI so just double-check before hitting the "commit suggestion" button if you want.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
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 to all who participated! ❤️ |
functools.reduce
accepts keyword arguments, while the C implementation does not #121676