-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Weird keyword parameter names in builtins #73881
Comments
Proposed patches deprecate the "x" keyword parameter in int(), bool() and float() and the "sequence" keyword parameter in list() and tuple(). Name "x" is meaningless, and name "sequence" is misleading (any iterable is accepted, not just sequence). The documentation uses name "iterable" for list() and tuple(). It is never documented that any of these parameters are accepted by keywords. There was only a test for int(), but it was added just for increasing coverity, not to test intended behavior. Does this mean that the support of keyword arguments can be removed without deprecation? The general idea got preliminary approval from Guido (https://mail.python.org/pipermail/python-ideas/2017-March/044959.html). |
I don't think we should do it without deprecation, since it could break working code. But it certainly sounds like a marginal case: I doubt there is *much* code that uses the existing keyword names. |
R. David Murray added the comment:
I'm not sure that it's worth it to add a deprecation warning in Python |
Well, I was feeling the same, but asked just for the case. Could you then look at deprecation messages? I'm sure that 'The "x" keyword argument of int() is deprecated' is not the best wording, and may be even ugly wording. Could you please suggest better wording David? Patches don't document new deprecations because it is not documented that keyword arguments are supported either. Is mentioning in What's New enough? |
"What's New in Python 3.7" has a section for such changes: "Porting to Oh, I see that you already made a similar change but this one had a See also the positional-only arguments discussion on python-ideas: |
So these will become positional only? In that case I'd say "Using 'x' as a keyword argument is deprecated; specify the value as a positional argument instead" |
See also bpo-20283. Obviously wrong keyword parameter names in regex methods were deprecated in 2.7, 3.3 and 3.4 and removed in 3.6. |
Thank you David! Updated warning messages for your suggestion and added entries in Misc/NEWS and What's New. |
I concur with Victor and Serhiy that we can bypass a deprecation phase here and just get it done. In the rare case of int(x=3.14), the fix is trivial. |
I already merged the patch as 58d23e6. If you think that it would be better to remove without deprecation, the following patch does this. |
I do think it would be better to not have the deprecation. |
@serhiy: Can you please create a PR for it? |
If David agrees with this. |
If Raymond is on the side of skipping the deprecation than I'm good with it. Like I said, this is a marginal case. |
Thanks all! |
Unhappy buildbot. http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.x/builds/456/steps/test/logs/stdio ====================================================================== Traceback (most recent call last):
File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_descr.py", line 3451, in test_keyword_arguments
list.__init__(a, sequence=[0, 1, 2])
TypeError: list() does not take keyword arguments ====================================================================== Traceback (most recent call last):
File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_descr.py", line 2888, in test_keywords
self.assertEqual(int(x=1), 1)
TypeError: 'x' is an invalid keyword argument for this function |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: