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
Argument Clinic: add support for deprecating positional use of parameters #95065
This will then generate code that emits a DeprecationWarning if optarg is passed as a positional argument, but not if it is passed as a keyword.
We can use this feature to introduce deprecation warnings for parameters that will become keyword-only in future releases. When the deprecation period is done, we can simply replace the x with *, to really make the optional params keyword-only.
It is recommended to make optional rarely used arguments keyword-only. I do not think it will break much code, but we need a deprecation period for this.
The problem is that sqlite3.connect() was converted to Argument Clinic, and it was much easier to add deprecation warning in the old code.
I think it is great idea, although I would like to use something more distinguishable and searchable than just x.
We should consider more general problem, when we want to change parameters in incompatible way.
Turn positional-or-keyword parameters into keyword-only parameters. A directive which means "the following positional-or-keyword parameters will be keyword-only parameters in future".
Turn positional-or-keyword parameters into positional-only parameters. A directive which means "the preceding positional-or-keyword parameters will be positional-only parameters in future".
Remove parameter. For some converters we can use NULL or something like to distinguish absent argument, but for others all values after conversion are correct, so we need a special directive for this. When remove positional-only or positional-or-keyword parameter, all following parameters should become keyword-only parameters.
Rename positional-or-keyword or keyword-only parameters. In meantime the function should accept both old and new keyword names, but raise an exception if both are passed or if the argument is passed as positional and keyword. For example see Wrong keyword parameter name in regex pattern methods #64482.
There may be other possible incompatible changes, but these four are common.
I think it is great idea, although I would like to use something more distinguishable and searchable than just x.
Thanks for the support! I'm up for any other symbol; x was just the first thing that popped up in my head when I did the first proof-of-concept implementation. OTOH, * and / are not very searchable either.
We should consider more general problem, when we want to change parameters in incompatible way. [...]
There may be other possible incompatible changes, but these four are common.
+1 However, I think we should create separate issues for each feature :)
I think we can close this now. The only thing missing is the preprocessor tests; I'm not sure it is worth it to add all the boilerplate code needed to get such tests up and running. If we feel it is needed, we can create a follow-up issue for that particular item, but I don't think it should keep blocking the resolution of this issue.
Activity
erlend-aasland commentedon Jul 20, 2022
If there is sufficient support for this feature, I'll create a PR.
erlend-aasland commentedon Jul 22, 2022
TwoThree thumbs up; I'll create the PR 😎zware commentedon Jul 22, 2022
I'd suggest to go full
warnings._deprecatedon it, with an error if the specified removal version has reached beta without the change.erlend-aasland commentedon Jul 23, 2022
Maybe I'm misunderstanding you, but that would imply extending the new syntax with optional deprecated version and removed version fields, right?
serhiy-storchaka commentedon Jul 23, 2022
I think it is great idea, although I would like to use something more distinguishable and searchable than just
x.We should consider more general problem, when we want to change parameters in incompatible way.
There may be other possible incompatible changes, but these four are common.
erlend-aasland commentedon Jul 23, 2022
Thanks for the support! I'm up for any other symbol;
xwas just the first thing that popped up in my head when I did the first proof-of-concept implementation. OTOH,*and/are not very searchable either.+1 However, I think we should create separate issues for each feature :)
hauntsaninja commentedon Dec 1, 2022
Thanks for suggesting this! This would be nice, e.g. for #56166
A quick bikeshed, do we need to use a new symbol? Something like the following seems pretty readable:
Over here
*-in-3.12is a suggestion for how we could specify we wantwarnings._deprecatedsemantics.erlend-aasland commentedon Dec 2, 2022
I don't know; I just picked that path, because it was very easy to implement as a proof of concept :)
Regarding the proposed extended format: I'd replace the hyphens with single whitespace to make it more readable.
erlend-aasland commentedon Jan 2, 2023
cc. @colorfulappl: this might be of interest to you.
18 remaining items
pythongh-95065: Argument Clinic: Add comment to preprocessor warning …
gh-95065: Argument Clinic: Add comment to preprocessor warning code (#…
pythongh-95065: Argument Clinic: Add functional tests of deprecated p…
pythongh-95065: Produce nicer deprecation messages in Argument Clinic
gh-95065: Produce nicer deprecation messages in Argument Clinic (#107808
gh-95065: Argument Clinic: Add functional tests of deprecated positio…
pythongh-95065, pythongh-107704: Argument Clinic: support multiple '/…
gh-95065, gh-107704: Argument Clinic: support multiple '/ [from ...]'…
serhiy-storchaka commentedon Aug 21, 2023
@erlend-aasland, do you mind to create issues for other two problems mentioned in #95065 (comment)? I could do them, but I am not sure about syntax.
erlend-aasland commentedon Aug 22, 2023
I'll get to it right away.
erlend-aasland commentedon Aug 22, 2023
I think we can close this now. The only thing missing is the preprocessor tests; I'm not sure it is worth it to add all the boilerplate code needed to get such tests up and running. If we feel it is needed, we can create a follow-up issue for that particular item, but I don't think it should keep blocking the resolution of this issue.
erlend-aasland commentedon Aug 22, 2023
Thanks again, to everyone involved!
python/cpython#95065: Add Argument Clinic support for deprecating pos…
python/cpython#95065: Add Argument Clinic support for deprecating pos…