Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wrapper(f, instance, args, kwargs):
if old_name in kwargs:
_utils.deprecation(out_message,
stacklevel=stacklevel, category=category)
return f(*args, **kwargs)
def decorator(wrapped, instance, args, kwargs):
if old_name in kwargs:
_utils.deprecation(out_message,
stacklevel=stacklevel, category=category)
if replace:
kwargs.setdefault(new_name, kwargs.pop(old_name))
return wrapped(*args, **kwargs)
def wrapper(wrapped, instance, args, kwargs):
base_name = _utils.get_class_name(wrapped, fully_qualified=False)
if fully_qualified:
old_name = old_attribute_name
else:
old_name = ".".join((base_name, old_attribute_name))
new_name = ".".join((base_name, new_attribute_name))
prefix = _KIND_MOVED_PREFIX_TPL % (kind, old_name, new_name)
out_message = _utils.generate_message(
prefix, message=message,
version=version, removal_version=removal_version)
_utils.deprecation(out_message, stacklevel=stacklevel,
category=category)
return wrapped(*args, **kwargs)
def wrapper(wrapped, instance, args, kwargs):
explicit_params = set(
varnames[:len(args)] + list(kwargs.keys())
)
allparams = set(varnames)
default_params = set(allparams - explicit_params)
if name in default_params:
_utils.deprecation(out_message,
stacklevel=stacklevel, category=category)
return wrapped(*args, **kwargs)
def old_new_func(*args, **kwargs):
_utils.deprecation(out_message, stacklevel=stacklevel,
category=category)
return new_func(*args, **kwargs)
fully_qualified=False)
if base_name:
thing_name = ".".join([base_name, f_name])
else:
thing_name = f_name
else:
thing_name = f_name
if thing_post:
thing_name += thing_post
prefix = prefix_pre + " '%s' is deprecated" % (thing_name)
out_message = _utils.generate_message(
prefix,
version=version,
removal_version=removal_version,
message=message)
_utils.deprecation(out_message,
stacklevel=stacklevel, category=category)
return f(*args, **kwargs)
return wrapper(f)
def __get__(self, instance, owner):
_utils.deprecation(self._message,
stacklevel=self._stacklevel,
category=self._category)
# This handles the descriptor being applied on a
# instance or a class and makes both work correctly...
if instance is not None:
real_owner = instance
else:
real_owner = owner
return getattr(real_owner, self._new_name)
elif isinstance(module, six.string_types):
module_name = module
else:
_qual, type_name = _utils.get_qualified_name(type(module))
raise TypeError("Unexpected module type '%s' (expected string or"
" module type only)" % type_name)
prefix = "The '%s' module usage is deprecated" % module_name
if replacement:
postfix = ", please use %s instead" % replacement
else:
postfix = None
out_message = _utils.generate_message(prefix,
postfix=postfix, message=message,
version=version,
removal_version=removal_version)
_utils.deprecation(out_message,
stacklevel=stacklevel, category=category)
:param version: version string (represents the version this
deprecation was created in)
:param removal_version: version string (represents the version this
deprecation will be removed in); a string of '?'
will denote this will be removed in some future
unknown version
:param stacklevel: stacklevel used in the :func:`warnings.warn` function
to locate where the users code is in the
:func:`warnings.warn` call
:param category: the :mod:`warnings` category to use, defaults to
:py:class:`DeprecationWarning` if not provided
"""
out_message = _utils.generate_message(prefix, postfix=postfix,
version=version, message=message,
removal_version=removal_version)
_utils.deprecation(out_message, stacklevel=stacklevel,
category=category)