okay
This commit is contained in:
parent
7331957ee4
commit
0e5cf0f840
@ -249,17 +249,14 @@ def deprecated(instead: Optional[str] = None) -> Callable[[Callable[P, T]], Call
|
||||
def actual_decorator(func: Callable[P, T]) -> Callable[P, T]:
|
||||
@functools.wraps(func)
|
||||
def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
|
||||
warnings.simplefilter(
|
||||
"always", DeprecationWarning) # turn off filter
|
||||
warnings.simplefilter("always", DeprecationWarning) # turn off filter
|
||||
if instead:
|
||||
fmt = "{0.__name__} is deprecated, use {1} instead."
|
||||
else:
|
||||
fmt = "{0.__name__} is deprecated."
|
||||
|
||||
warnings.warn(fmt.format(func, instead),
|
||||
stacklevel=3, category=DeprecationWarning)
|
||||
warnings.simplefilter(
|
||||
"default", DeprecationWarning) # reset filter
|
||||
warnings.warn(fmt.format(func, instead), stacklevel=3, category=DeprecationWarning)
|
||||
warnings.simplefilter("default", DeprecationWarning) # reset filter
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return decorated
|
||||
|
Loading…
x
Reference in New Issue
Block a user