-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make arguments to @deprecated/warn_deprecated keyword-only. #12440
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
Conversation
(except for the deprecated-since version) In 2.2 there were quite a few deprecation warnings of the form ``` warn_deprecated("2.2", "name-of-the-deprecated-API") ``` (e.g. passing 'box-forced' to set_adjustable, or the 'fig' kwarg to get_subplot_params). Such warnings would just display the name of the deprecated API when triggered, without actually including a deprecation message or the deprecated-since version. This is because the correct call would have been ``` warn_deprecated("2.2", name="name-of-the-deprecated-API") ``` (leaving `message` -- the first arg -- to None, and getting an autogenerated message). To avoid this, make all args to `warn_deprecated` and `@deprecated` keyword-only (except the deprecated-since version). There is no deprecation period on the old signature of these deprecator functions(!) because they are clearly intended for internal use, because handling signature changes is a bit of a pain and because deprecations on the deprecation machinery is a bit too meta.
9d51663
to
3f12eae
Compare
I'm confused, there don't seem to be any changes to |
@@ -52,8 +52,8 @@ def _generate_deprecation_message( | |||
|
|||
|
|||
def warn_deprecated( | |||
since, message='', name='', alternative='', pending=False, | |||
obj_type='attribute', addendum='', *, removal=''): | |||
since, *, message='', name='', alternative='', pending=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's the relevant change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, even since
could be keyword-only. I've been confused in the beginning if it's the version this got deprecated in or if it's the version this will be removed in. Getting used to it now as I encounter it more and more, but it's not self-explanatory for new readers of the code.
I think that's too wordy to be worth it (that's literally all calls to deprecated/warn_deprecated), but I don't care that much either way. |
@dstansby (pinging you as you already reviewed above) Are you OK with the changes? |
(except for the deprecated-since version)
In 2.2 there were quite a few deprecation warnings of the form
(e.g. passing 'box-forced' to set_adjustable, or the 'fig' kwarg to
get_subplot_params).
Such warnings would just display the name of the deprecated API when
triggered, without actually including a deprecation message or the
deprecated-since version. This is because the correct call would have
been
(leaving
message
-- the first arg -- to None, and getting anautogenerated message).
To avoid this, make all args to
warn_deprecated
and@deprecated
keyword-only (except the deprecated-since version).
There is no deprecation period on the old signature of these deprecator
functions(!) because they are clearly intended for internal use, because
handling signature changes is a bit of a pain and because deprecations
on the deprecation machinery is a bit too meta.
PR Summary
PR Checklist