Vintage¶
Overview¶
Vintage is a library to help you manage code deprecation cycles. It provides a decorator, deprecated
, which marks functions and methods as deprecated
Usage¶
Decorate your functions with deprecated
, optionally providing a message:
>>> from vintage import deprecated
>>> @deprecated
... def my_old_func(a, b, c):
... return a + b +c
>>> my_old_func(1, 2, 3)
1: DeprecationWarning: __main__.my_old_func is deprecated.
6
You can also provide an explicit message:
>>> @deprecated(message='Use new_func instead')
... def my_old_func(a, b, c):
... return a + b +c
>>> my_old_func(1, 2, 3)
1: DeprecationWarning: __main__.my_old_func is deprecated. Use new_func instead
6
Deprecations can also be emitted by using a dedicated function:
>>> vintage.warn_deprecation('use other thing')
Suppressing Deprecations¶
Vintage allows suppressing deprecations through the get_no_deprecations_context
context:
>>> with vintage.get_no_deprecations_context():
... # deprecated code here
Note
The above context does not meddle with Python’s warning mechanism, but rather suppresses Vintage deprecations only. This is useful as it does not interfere with current warning settings and/or capturing contexts. However, it means that other pieces of code emitting deprecation warnings directly would not get suppressed