1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
import warnings
from deprecated import deprecated
class MyDeprecationWarning(DeprecationWarning):
""" My DeprecationWarning """
class DeprecatedIn26(MyDeprecationWarning):
""" deprecated in 2.6 """
class DeprecatedIn30(MyDeprecationWarning):
""" deprecated in 3.0 """
@deprecated(category=DeprecatedIn26, reason="deprecated function")
def foo():
print("foo")
@deprecated(category=DeprecatedIn30, reason="deprecated function")
def bar():
print("bar")
if __name__ == '__main__':
warnings.filterwarnings("ignore", category=DeprecatedIn30)
foo()
bar()
|