Skip to content

BUG,ENH: make deprecated decorator work (and more flexibly) #7651

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

Merged
merged 1 commit into from
Dec 22, 2016

Conversation

efiring
Copy link
Member

@efiring efiring commented Dec 20, 2016

  1. Fix the bug in which _generate_deprecation_message was failing
    to substitute arguments for string formats in user-supplied
    message argument.
  2. Make internal naming consistent: the argument is "name", and
    now the string format specifications also use "name", not "func".
  3. Add an "addendum" kwarg so that the standard message, with its
    convenient argument substitution, can be used, and additional
    explanation can be appended as a plain text string.

Closes #7647.

1) Fix the bug in which _generate_deprecation_message was failing
   to substitute arguments for string formats in user-supplied
   message argument.
2) Make internal naming consistent: the argument is "name", and
   now the string format specifications also use "name", not "func".
3) Add an "addendum" kwarg so that the standard message, with its
   convenient argument substitution, can be used, and additional
   explanation can be appended as a plain text string.

Closes matplotlib#7647.
@efiring efiring added this to the 2.1 (next point release) milestone Dec 20, 2016
@NelleV
Copy link
Member

NelleV commented Dec 21, 2016

My two cents on our deprecation functions is that they are extremely complicated to use and hard to predict what the deprecation message is going to be. Is there a way to simplify that?

@efiring
Copy link
Member Author

efiring commented Dec 21, 2016

This PR should make it quite a bit easier; in most cases, just leave all kwargs but the last as defaults (unless "alternative" can be specified) and put additional information in "addendum". That way, the message always starts out with the standard pattern, automatically identifying what is being deprecated and when.

Also, part of the difficulty you experienced might have been because the behavior did not match the documentation--there was a huge bug, which this PR fixes.

Additional steps to make it easier would be adding full examples to the documentation, showing exactly what happens by default, and with common combinations of kwargs.

@NelleV
Copy link
Member

NelleV commented Dec 21, 2016

My strategy is currently to git grep and see what people do or to provide explicitely the deprecation message :)

@tacaswell
Copy link
Member

@amueller 's https://github.com/amueller/futurepast might be interesting to look at here as well.

@NelleV NelleV merged commit 266d524 into matplotlib:master Dec 22, 2016
@amueller
Copy link
Contributor

unfortunately futurepast is not really ready for consumption yet. I'd be happy to check out what needs to be done to make your use-cases more simple. That library needs like a week of crunch-time then it should be ok lol

@efiring
Copy link
Member Author

efiring commented Dec 29, 2016

I think the system we have right now, with the present PR merged, serves our purposes well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants