qcodes/utils/deprecate.py
def deprecate(
        reason: Optional[str] = None,
        alternative: Optional[str] = None
) -> Callable[..., Any]:
    """
    A utility function to decorate deprecated functions and classes.

    Args:
        reason: The reason of deprecation.
        alternative: The alternative function or class to put in use instead of
            the deprecated one.

    """

    @wrapt.decorator  # type: ignore[misc]
    def decorate_callable(func: Callable[..., Any],
                          instance: object, args: Any, kwargs: Any) -> Any:
        t, n = (('class', instance.__class__.__name__)
                if func.__name__ == '__init__'
                else ('function', func.__name__))
        issue_deprecation_warning(f'{t} <{n}>', reason, alternative)
        return func(*args, **kwargs)

    def actual_decorator(obj: Any) -> Any:
        if isinstance(obj, (types.FunctionType, types.MethodType)):
            func = cast(Callable[..., Any], obj)
            # pylint: disable=no-value-for-parameter
            return decorate_callable(func)
            # pylint: enable=no-value-for-parameter
        else:
            # this would need to be recursive
            for m_name in dir(obj):
                m = getattr(obj, m_name)
                if isinstance(m, (types.FunctionType, types.MethodType)):
                    # skip static methods, since they are not wrapped correctly
                    # by wrapt.
                    # if anyone reading this knows how the following line
                    # works please let me know.
                    if isinstance(obj.__dict__.get(m_name, None), staticmethod):
                        continue
                    # pylint: disable=no-value-for-parameter
                    setattr(obj, m_name, decorate_callable(m))
                    # pylint: enable=no-value-for-parameter
            return obj

    return actual_decorator

    A utility function to decorate deprecated functions and classes.

    Args:
        reason: The reason of deprecation.
        alternative: The alternative function or class to put in use instead of
            the deprecated one.

    
A utility function to decorate deprecated functions and classes.
A utility function to decorate deprecated functions and classes .
def deprecate(
        reason: Optional[str] = None,
        alternative: Optional[str] = None
) -> Callable[..., Any]:
    @wrapt.decorator  
    def decorate_callable(func: Callable[..., Any],
                          instance: object, args: Any, kwargs: Any) -> Any:
        t, n = (('class', instance.__class__.__name__)
                if func.__name__ == '__init__'
                else ('function', func.__name__))
        issue_deprecation_warning(f'{t} <{n}>', reason, alternative)
        return func(*args, **kwargs)
    def actual_decorator(obj: Any) -> Any:
        if isinstance(obj, (types.FunctionType, types.MethodType)):
            func = cast(Callable[..., Any], obj)
            return decorate_callable(func)
        else:
            for m_name in dir(obj):
                m = getattr(obj, m_name)
                if isinstance(m, (types.FunctionType, types.MethodType)):
                    if isinstance(obj.__dict__.get(m_name, None), staticmethod):
                        continue
                    setattr(obj, m_name, decorate_callable(m))
            return obj
    return actual_decorator
def deprecate ( reason : Optional [ str ] = None , alternative : Optional [ str ] = None ) -> Callable [ ... , Any ] : @ wrapt . decorator def decorate_callable ( func : Callable [ ... , Any ] , instance : object , args : Any , kwargs : Any ) -> Any : t , n = ( ( 'class' , instance . __class__ . __name__ ) if func . __name__ == '__init__' else ( 'function' , func . __name__ ) ) issue_deprecation_warning ( f'{t} <{n}>' , reason , alternative ) return func ( * args , ** kwargs ) def actual_decorator ( obj : Any ) -> Any : if isinstance ( obj , ( types . FunctionType , types . MethodType ) ) : func = cast ( Callable [ ... , Any ] , obj ) return decorate_callable ( func ) else : for m_name in dir ( obj ) : m = getattr ( obj , m_name ) if isinstance ( m , ( types . FunctionType , types . MethodType ) ) : if isinstance ( obj . __dict__ . get ( m_name , None ) , staticmethod ) : continue setattr ( obj , m_name , decorate_callable ( m ) ) return obj return actual_decorator
A utility function to decorate deprecated functions and classes.
A utility function to decorate deprecated functions and classes .
"""
    A utility function to decorate deprecated functions and classes.

    Args:
        reason: The reason of deprecation.
        alternative: The alternative function or class to put in use instead of
            the deprecated one.

    """ # type: ignore[misc] # pylint: disable=no-value-for-parameter # pylint: enable=no-value-for-parameter # this would need to be recursive # skip static methods, since they are not wrapped correctly # by wrapt. # if anyone reading this knows how the following line # works please let me know. # pylint: disable=no-value-for-parameter # pylint: enable=no-value-for-parameter
reason
Optional[str]
The reason of deprecation.
The reason of deprecation .
alternative
Optional[str]
The alternative function or class to put in use instead of
the deprecated one.
The alternative function or class to put in use instead of the deprecated one .