-
-
Notifications
You must be signed in to change notification settings - Fork 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
refactor(python): Improve deprecation utils #10167
Conversation
4321dfb
to
9a34bdf
Compare
I like the inclusion of versioning info (and some of the renames are definite wins). So, a few small suggestions! Instead of... @deprecate_argument_name("fmt", "format", version="0.17.3") ...how about this: @deprecate_param_name( before_after={"fmt": "format"}, as_of="0.17.3") You could still stack the decorator if the same method experiences multiple separate deprecations (let's hope this is rare, heh), but if more than one param is changed at a time then the dict format connects those changes better, and Using |
5c16ee3
to
1946189
Compare
I think "parameter" is more correct here. Changed to
I don't really like the dict input here. As you mention, it's a rare occurrence that we would deprecate multiple args in the same version, and in the 98% of cases where this is NOT the case, the flat parameters old/new make more sense. If we do have multiple deprecations, they are adequately coupled by having the same version number.
Agreed, though |
When this is our hardest problem we're doing pretty well! 😁
Yup, don't disagree; no need to prioritise the edgiest of edge-cases.
True... however, my first thought on seeing |
All right, I'll go ahead with the current version. We can update later if we think of the perfect variable name :) Thanks for the input! |
Partially addresses #8004
Followup of #10147
Changes:
deprecated_alias
utildeprecate_argument_name
deprecate_renamed_parameter
version
keyword argument to specify when the deprecation happened.redirect
util todeprecate_renamed_methods
. Now requires aversions
keyword argument.I think this now gives us quite a solid set of utils for doing deprecations:
issue_deprecation_warning
deprecate_function
deprecate_renamed_function
deprecate_renamed_parameter
deprecate_renamed_methods
deprecate_nonkeyword_arguments
@alexander-beedie I would appreciate your input on these changes, as I know you've originally written most of these utils!
EDIT:
Actually, probably theI can't figure this one out - I don't think it can be done in the current setup as a class decorator overwriting thedeprecate_renamed_methods
decorator should also be a 'stacking' decorator redirecting only 1 method. Putting this on 'draft' for now until I have time to update.__getattr__
dunder. Let's leave it like this until we come up with a better approach.