Dandelyon
Eventually, everything will come to an end.
There is no difference with code.
Deprecation should be easy, efficient and predictable.
With the the help of a few decorator functions, you can communicate to your users any changes occurring in upcoming releases.
Getting Started
Install with
pip install dandelyon
A simple deprecation warning
from dandelyon import dandelyon
@dandelyon.warn(message='Please consider using bar()')
def foo():
return 'Fire!'
res = foo()
print(res)
# 'Fire'
-----
# In your logs
# "Warning: Foo is a deprecated function. Please consider using bar()"
*A shuttle from one function to another
def bar():
return 'This is new'
@dandelyon.shuttle(ff=bar)
def foo():
return 'This is old'
res = foo()
print(res)
# 'This is new'
Or add new parameters...
def bar(bar, baz):
return 'This is a new {} {}'.format(bar, baz)
@dandelyon.alias(ff=bar)
def foo():
return 'This is old'
res = foo('function', 'junction')
print(res)
# 'This is a new function junction'
Add a date where the function will deprecate and forward
expiry_date = datetime.datetime(2200, 1, 1)
def bar(bar, baz):
return 'This is new a {} {}'.format(bar, baz)
@dandelyon.countdown(expires=expiry_date,
message='Please consider using bar().',
ff=bar)
def foo(bar, *args, **kwargs):
return 'This is an old {}'.format(bar)
res = foo('function', 'junction')
# Before year 2200
print(res)
# 'This is an old function'
-----
# In your logs:
# Warning: "foo() is a deprecated function and it will be removed by 1-1-2200. Please consider using bar()."
# Later in time...
print(res)
# This is a new function junction
Dependencies
None
Running the tests
python setup.py test
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Authors
- Andrew Graham-Yooll
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Add your name here!