Skip to content

Commit

Permalink
✨ feat: add useDeprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
mic1on committed Dec 23, 2023
1 parent 014e27e commit 11b43bc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/usepy/core/useDeprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import warnings
from functools import wraps


def useDeprecated(use_instead=None):
"""
mark functions as deprecated
"""

def deco(func):
@wraps(func)
def wrapped(*args, **kwargs):
message = "Call to deprecated function %s." % func.__name__
if use_instead:
message += " Use %s instead." % use_instead
warnings.warn(message, stacklevel=2)
return func(*args, **kwargs)

return wrapped

if callable(use_instead):
deco = deco(use_instead)
use_instead = None
return deco

0 comments on commit 11b43bc

Please sign in to comment.