Skip to content

Commit

Permalink
Remove grab.util.warning::deprecated decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Some User committed Feb 25, 2022
1 parent ae89979 commit 0af0dea
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions grab/util/warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,7 @@ class GrabDeprecationWarning(UserWarning):

def warn(msg, stacklevel=2):
warnings.warn(msg, category=GrabDeprecationWarning, stacklevel=stacklevel)
frame = sys._getframe() # pylint: disable=protected-access
logging.debug('Deprecation Warning\n%s',
''.join(traceback.format_stack(f=frame.f_back)))


# from https://github.com/scrapy/scrapy/blob/master/scrapy/utils/decorator.py
def deprecated(use_instead=None):
"""This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used."""

def wrapped(func):
@wraps(func)
def new_func(*args, **kwargs):
message = "Call to deprecated function %s." % func.__name__
if use_instead:
message += " Use %s instead." % use_instead
if not DISABLE_WARNINGS:
warn(message, stacklevel=3)
return func(*args, **kwargs)
return new_func
return wrapped
frame = sys._getframe() # pylint: disable=protected-access
logging.debug(
"Deprecation Warning\n%s", "".join(traceback.format_stack(f=frame.f_back))
)

0 comments on commit 0af0dea

Please sign in to comment.