_deprecated.py
1 # SPDX-License-Identifier: MIT 2 # 3 # Copyright (c) 2021 The Anvil Extras project team members listed at 4 # https://github.com/anvilistas/anvil-extras/graphs/contributors 5 # 6 # This software is published at https://github.com/anvilistas/anvil-extras 7 8 from functools import wraps 9 10 __version__ = "3.1.0" 11 12 13 def deprecated(msg=""): 14 def outer(fn): 15 # nonlocal not available 16 warned = [False] 17 18 @wraps(fn) 19 def wrapper(*args, **kws): 20 if not warned[0]: 21 warned[0] = True 22 print("DeprecatedWarning:", msg) 23 24 return fn(*args, **kws) 25 26 return wrapper 27 28 return outer