Skip to content

Commit

Permalink
simplify decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
zpcore committed Jul 17, 2024
1 parent 7bb16fa commit 9422bd8
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions torch_xla/experimental/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,9 @@ def mark_deprecated(module, new: FN) -> FN:
Returns:
Wrapper of the new function.
"""
already_warned = [False]

def decorator(func):

@functools.wraps(new)
def wrapped(*args, **kwargs):
if not already_warned[0]:
logging.warning(
f'{module.__name__}.{func.__name__} is deprecated. Use {new.__module__}.{new.__name__} instead.'
)
already_warned[0] = True

return new(*args, **kwargs)

return wrapped
return deprecated(module, new, old_name=func.__name__)

return decorator

Expand Down

0 comments on commit 9422bd8

Please sign in to comment.