File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
templates/python/package/utils Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -29,14 +29,16 @@ def deprecated(reason=None):
2929
3030 @functools.wraps(func)
3131 def wrapped(*args, **kwargs):
32- warnings.simplefilter('always', DeprecationWarning) # turn off filter
33- warnings.warn(
34- message,
35- category=DeprecationWarning,
36- stacklevel=2
37- )
38- warnings.simplefilter('default', DeprecationWarning) # reset filter
39- return func(*args, **kwargs)
32+ warnings.simplefilter('always', DeprecationWarning) # show warning every time
33+ try:
34+ warnings.warn(
35+ message,
36+ category=DeprecationWarning,
37+ stacklevel=2
38+ )
39+ return func(*args, **kwargs)
40+ finally:
41+ warnings.simplefilter('default', DeprecationWarning) # reset filter
4042 return wrapped
4143
4244 # Support both @deprecated and @deprecated("reason")
You can’t perform that action at this time.
0 commit comments