Skip to content

Commit

Permalink
Fix typo and stacklevel
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Jun 10, 2020
1 parent 0a3824d commit b37e34c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions torchaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@
pass


@_mod_utils.depricate("Use `torchaudio.sox_effects.init_sox_effects`.")
@_mod_utils.deprecated(
"Use `torchaudio.sox_effects.init_sox_effects`, or simply remove the call. "
"It is automatically handled."
)
def initialize_sox():
init_sox_effects()


@_mod_utils.depricate("Use `torchaudio.sox_effects.shutdown_sox`.")
@_mod_utils.deprecated(
"Use `torchaudio.sox_effects.shutdown_sox`, or remove the call. "
"It is automatically handled."
)
def shutdown_sox():
shutdown_sox_effects()

Expand Down
11 changes: 8 additions & 3 deletions torchaudio/_internal/module_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ def wrapped(*args, **kwargs):
return decorator


def depricate(direction: str):
"""Decorator to add depciration message"""
def deprecated(direction: str):
"""Decorator to add deprecation message
Args:
direction: Migration steps to be given to users.
"""
def decorator(func):
@wraps(func)
def wrapped(*args, **kwargs):
warnings.warn(f'{func.__module__}.{func.__name__} has been deprecated. f{direction}')
message = f'{func.__module__}.{func.__name__} has been deprecated. f{direction}'
warnings.warn(message, stacklevel=2)
return func(*args, **kwargs)
return wrapped
return decorator

0 comments on commit b37e34c

Please sign in to comment.