-
-
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
Argument Clinic: add support for deprecating positional use of parameters #95065
Comments
If there is sufficient support for this feature, I'll create a PR. |
|
I'd suggest to go full |
Maybe I'm misunderstanding you, but that would imply extending the new syntax with optional deprecated version and removed version fields, right? |
I think it is great idea, although I would like to use something more distinguishable and searchable than just 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. |
Thanks for the support! I'm up for any other symbol;
+1 However, I think we should create separate issues for each feature :) |
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 |
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. |
cc. @colorfulappl: this might be of interest to you. |
Expanding on @hauntsaninja's bikeshedding in #95065 (comment): All of these should mean: "positional use is deprecated; param will be keyword only starting from 3.14":
|
Example clinic code using the second suggestion from #95065 (comment):
Now, let's deprecate stuff:
|
I have no preferences of used words, but if use spaces, I would prefer to use also some parenthesis. |
Yeah, the parentheses look nice. Also, I think we should not allow deprecations without a deadline. |
Some additional suggestions:
If the
Or, combining two approaches:
Not meant to be fully fleshed out, but hopefully might provoke other ideas! A |
I updated #95151 using @AA-Turner's suggested format (simply since I like that best, personally 😄). For now, I've keep the feature dead simple; there is no support for multiple sets of deprecations. IMO, it would be wise to add a simple variant of the feature first, try it out, and then add support for multiple deprecation variants later. @zware, I added preprocessor whining if clinic code has not been updated yet. Hopefully it is not too whiny :) (I guess |
Suggestions for follow-up PRs after #95151 lands:
|
For multiple deprecation layers, I believe we want:
|
…of parameters (#95151) It is now possible to deprecate passing parameters positionally with Argument Clinic, using the new '* [from X.Y]' syntax. (To be read as "keyword-only from Python version X.Y") Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
One potential downside of a consolidated deprecation message is that it is harder to filter on parts -- e.g. if you have migrated all usages of parameter X to keyword, but not Y, you could filter out the Y warnings in your test suite, but ensure that any new X warnings cause test failures. I don't know how realistic this would be though, as you might just migrate all parameters at once rather than in stages. A |
…ode (#107712) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
See gh-107742 for a rough proof-of-concept; I'm not sure this feature is worth it. At the moment, I think we should play with what we've got. If the need arises, we can consider expanding the feature so multiple deprecation layers/groups are supported. |
One thing I thought of that could be nice, though, is to append the deprecation warning to the docstring. See gh-107745 for a suggestion on how to do this. |
…ositionals Move the "deprecated positinal" tests from clinic.test.c to _testclinic.c. Mock PY_VERSION_HEX in order to prevent the generated compiler warnings/errors to trigger. Put clinic code for deprecated positionals in Modules/clinic/_testclinic_depr_star.c.h for easy inspection of the generated code.
…nals (#107768) Move the "deprecated positinal" tests from clinic.test.c to _testclinic.c. Mock PY_VERSION_HEX in order to prevent generated compiler warnings/errors to trigger. Put clinic code for deprecated positionals in Modules/clinic/_testclinic_depr_star.c.h for easy inspection of the generated code. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
… [from ...]' and '* [from ...]' markers
@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. |
I'll get to it right away. |
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. |
Thanks again, to everyone involved! |
…itional use of parameters (python/cpython#95151) It is now possible to deprecate passing parameters positionally with Argument Clinic, using the new '* [from X.Y]' syntax. (To be read as "keyword-only from Python version X.Y") Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…itional use of parameters (python/cpython#95151) It is now possible to deprecate passing parameters positionally with Argument Clinic, using the new '* [from X.Y]' syntax. (To be read as "keyword-only from Python version X.Y") Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Feature or enhancement
Suggesting to add syntax for producing deprecation warnings for positional use of optional parameters.
I made a proof-of-concept patch for this where I introduced a new special symbol
x
. Example use: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.Pitch
Quoting @serhiy-storchaka, in issue #93057:
Previous discussion
Linked PRs
The text was updated successfully, but these errors were encountered: