Skip to content
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

Feature: Issue DeprecationWarnings/DeprecationErrors when calling API changes #17

Open
kmuehlbauer opened this issue Feb 23, 2018 · 2 comments

Comments

@kmuehlbauer
Copy link
Contributor

Here I would like to discuss the possibility to extend the functionality of this package to notice about forthcoming API changes and the like.

In many cases functions/classes/methods (you name it) are not deprecated but a change in the API will take place. So it would be useful to warn the user about forthcoming changes with a special decorator.

We used this in the past in our package but would like to see it added here, where it belongs (IMHO). Please have a look at possible use cases here.

The current code would naturally need quite bit of lifting to adapt it to this packages style.

Thoughts?

@briancurtin
Copy link
Owner

  1. I would be fine adding support for FutureWarning when current_version < deprecated_in. That part should be fairly easy on its own, just going from our two-state check between deprecated and removed to looking at the version against the three states of future, deprecated, and removed.

  2. Getting into looking at the caller's kwargs and figuring out types and stuff is probably further than I think this decorator should go as a general purpose library. What if there was some parameter to deprecated that was a callable that received the caller's *args, **kwargs and did that determination itself? For example, this is just pseudo-code, but what if the details parameter took that callable argument and generated the details from it?

def arg_checker(*args, **kwargs):
    if "x" in kwargs":
        if isinstance(kwargs["x"], int):
            return "x will become a str in 0.5"

@deprecated(deprecated_in="0.5", current_version="0.2",
            details=arg_checker)
def func(a, b, x=None, y=None):
    ...

@kmuehlbauer
Copy link
Contributor Author

@briancurtin Thank you for the comment. Especially the idea with the 'arg_checker' is charming. This will keep the flexibility at the user side and the simple code in the package.

I'll think about this a day or two.

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

No branches or pull requests

2 participants