-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Argument Clinic: add support for renaming a parameter #108271
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
Comments
Brainstorming regarding syntax, my first thought would be to modify
Something like this would be cleaner:
Here's another alternative, which require changes to
|
An
|
I considered similar variants:
In addition to adding this feature we can add also allow add a parameter alias without deprecating the old name. One feature can be considered an extension of the other. What are ideas for this syntax? How can it be extended to add the deprecation of the old name? Should we support more than two names for the same parameter? |
I think there is value in keeping the DSL simple, so perhaps an argument to converter is the best option. I agree it is not ideal mixing converter and param arguments, but as you say, we already do. |
I worry that the decorator variant will be too complex for little gain. I agree it also looks weird. |
Without having read this issue beforehand, the syntax variant I came up with for this was:
style. The need that made me ponder it came out of #134713 where hashlib has a param that pre-dates positional only but always should've been positional only (too late for that) that is alternatively called data or string in various places and we want to settle on the single data= name. I threw a Claude Code at adding easier support for this multi-name argument feature into argument clinic. It got something basic working but it wasn't sufficient for me to push forward with as it was getting tangled up on some of the generated C details and I didn't want to spend time on that myself. If my branch has anything worth sharing I'll attach a draft PR of it here for reference. The hashlib need isn't quite one of renaming a parameter as this was opened for. It is more one of accepting multiple names for the same thing (exclusively, making it an error to supply more than one of the positional & names) and while optionally deprecating some of them. Very similar in spirit though. |
Currently, Two first items from my plan has already been implemented. Removing and renaming a parameter are related, removing can be considered as renaming to null. So the syntax and the implementation can be similar. |
Uh oh!
There was an error while loading. Please reload this page.
Originally posted by @serhiy-storchaka in #95065 (comment):
The text was updated successfully, but these errors were encountered: