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]:
|
def actual_decorator(func: Callable[P, T]) -> Callable[P, T]:
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
|
def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
|
||||||
warnings.simplefilter(
|
warnings.simplefilter("always", DeprecationWarning) # turn off filter
|
||||||
"always", DeprecationWarning) # turn off filter
|
|
||||||
if instead:
|
if instead:
|
||||||
fmt = "{0.__name__} is deprecated, use {1} instead."
|
fmt = "{0.__name__} is deprecated, use {1} instead."
|
||||||
else:
|
else:
|
||||||
fmt = "{0.__name__} is deprecated."
|
fmt = "{0.__name__} is deprecated."
|
||||||
|
|
||||||
warnings.warn(fmt.format(func, instead),
|
warnings.warn(fmt.format(func, instead), stacklevel=3, category=DeprecationWarning)
|
||||||
stacklevel=3, category=DeprecationWarning)
|
warnings.simplefilter("default", DeprecationWarning) # reset filter
|
||||||
warnings.simplefilter(
|
|
||||||
"default", DeprecationWarning) # reset filter
|
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return decorated
|
return decorated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user