Uh oh!
There was an error while loading. Please reload this page.
decorator to deprecate positional arguments - #6910
Conversation
hmaarrfk
commented
Aug 12, 2022
Are the functions you are considering using this functions that never had keyword arguments before? When I wrote a similar decorator before i had an explicit list of arguments that were allowed to be converted. |
headtr1ck
commented
Aug 12, 2022
Do you think that you can get it to work with static typing? |
mathause
commented
Aug 12, 2022
No, I want to consider arguments that have default values. defmean(dim, skipna=None, keep_attrs=None):
pass@_deprecate_positional_args("v0.1.0")defmean(dim, *, skipna=None, keep_attrs=None):
passOr do I missunderstand your question?
I think |
I just realized that there is a bug in the decorator for "keyword-only arguments without a default". I wonder if I should fix this or just disallow this pattern, i.e. the following does currently not work properly: @_deprecate_positional_args("v0.1.0")deffunc(a, *, b):
passbut I am not sure how helpful it is. EDIT: It now raises a |
mathause
commented
Aug 12, 2022
I also just realized, that we made many arguments keyword-only without deprecation (e.g. |
mathause
commented
Aug 17, 2022
Any objections to merge this as is? |
dcherian
commented
Aug 17, 2022
👍 put it on the meeting agenda for today |
| print(f"{args=}") | ||
| print(f"{pos_or_kw_args=}") |
There was a problem hiding this comment.
are these print statements intentional?
There was a problem hiding this comment.
@mathause I think you missed these print statements?
There was a problem hiding this comment.
Thanks! Will fix them in a follow up!
| @@ -0,0 +1,86 @@ | |||
| import inspect | |||
There was a problem hiding this comment.
I would suggest keeping the original copyright notice at the top of the this file.
whats-new.rstapi.rstAdds a helper function to deprecate positional arguments. IMHO this offers a good trade-off between magic and complexity. (As mentioned this was adapted from scikit-learn).
edit: I suggest to actually deprecate positional arguments in another PR.