-
Notifications
You must be signed in to change notification settings - Fork 34
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
[RFC] deprecate an old parameter in favor of a new one #5
Comments
Hi Joan, Deprecating a parameter (for instance when you want to rename a parameter) means that the function signature is changing. So, the function itself is changing… Deprecating a function parameter is similar to deprecate the function. You can have: # coding: utf-8
from deprecated import deprecated
@deprecated(version="0.2.3",
reason="The *i* parameter is deprecated, "
"you may consider using *increment* instead.")
def my_add(x, i=None, increment=0):
increment = increment if i is None else i
return x + increment
print(my_add(5, i=9)) You get:
|
In the other hand, if you want to document the deprecation in Sphinx, you can use # coding: utf-8
from deprecated.sphinx import deprecated
@deprecated(version="0.2.3",
reason="The *i* parameter is deprecated, "
"you may consider using *increment* instead.")
def my_add(x, i=None, increment=0):
"""
This function adds *x* and *increment*.
:param x: The *x* value.
:param i: *i* parameter is deprecated, use *increment* instead.
:param increment: The increment value.
:return: sum of *x* and *increment*.
"""
increment = increment if i is None else i
return x + increment
print(my_add.__doc__) You get:
|
Yes. What you are proposing is close to what we had before. I guess that what I was asking was if you would be interested in such a feature. A decorator that took care of the old parameter. And if so, how do you guys want me to contribute the software? |
I created a module that does something like this: https://github.com/flying-sheep/legacy-api-wrap It currently doesn’t do anything when a removed parameter is provided, but the code can be easily extended to accommodate that. Would you like to merge with my project here? I think |
Ok, I understand what you mean @flying-sheep, If you had to write the documentation of a function with your |
I’d give the end user the new docs, and mention the old API in a
|
Hello, I just wanted to point out that I found this gist today that is related to this issue. https://gist.github.com/rfezzani/002181c8667ec4c671421a4d938167eb I looked at |
Parameter-level depreciation is currently being developed. Stay tune. |
I checked deprecated and other packages in search of this and I couldn't find it. So I end up making my own deprecation help function mne-tools/mne-python#5844
Check it out and if you think this is desirable, maybe we can cut a PR out of it.
The text was updated successfully, but these errors were encountered: