Skip to content

Commit

Permalink
Update message
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Jun 11, 2020
1 parent 6733129 commit 0336b12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 2 additions & 6 deletions torchaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@


@_mod_utils.deprecated(
"Use `torchaudio.sox_effects.init_sox_effects`, or simply remove the call. "
"It is automatically handled."
)
"Please remove the function call. Resource initialization is automatically handled")
def initialize_sox() -> int:
"""Initialize sox effects.
Expand All @@ -48,9 +46,7 @@ def initialize_sox() -> int:


@_mod_utils.deprecated(
"Use `torchaudio.sox_effects.shutdown_sox`, or remove the call. "
"It is automatically handled."
)
"Please remove the function call. Resource clean up is automatically handled")
def shutdown_sox():
"""Shutdown sox effects.
Expand Down
8 changes: 6 additions & 2 deletions torchaudio/_internal/module_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import warnings
import importlib.util
from typing import Optional
from functools import wraps


Expand Down Expand Up @@ -36,7 +37,7 @@ def wrapped(*args, **kwargs):
return decorator


def deprecated(direction: str):
def deprecated(direction: str, version: Optional[str] = None):
"""Decorator to add deprecation message
Args:
Expand All @@ -45,7 +46,10 @@ def deprecated(direction: str):
def decorator(func):
@wraps(func)
def wrapped(*args, **kwargs):
message = f'{func.__module__}.{func.__name__} has been deprecated. f{direction}'
message = (
f'{func.__module__}.{func.__name__} has been deprecated '
f'and will be removed from {"future" if version is None else version} release.'
f'{direction}')
warnings.warn(message, stacklevel=2)
return func(*args, **kwargs)
return wrapped
Expand Down

0 comments on commit 0336b12

Please sign in to comment.