U
    ꥡc                     @   s8   d dl Z d dlZG dd deZdddZd	ddZdS )
    Nc                   @   s   e Zd ZdS )AltairDeprecationWarningN)__name__
__module____qualname__ r   r   </tmp/pip-unpacked-wheel-y9_o96ar/altair/utils/deprecation.pyr      s   r   c                    s    fdd}|S )zDecorator to deprecate a function or class.

    Parameters
    ----------
    message : string (optional)
        The deprecation message
    c                    s   t |  dS )Nmessage)
_deprecate)objr   r   r   wrapper   s    zdeprecated.<locals>.wrapperr   )r	   r   r   r   r   
deprecated	   s    	r   c                    sz    dkrd |j ttr@t|fjtjd dS trdt	 fdd}|S t
d tdS )au  Return a version of a class or function that raises a deprecation warning.

    Parameters
    ----------
    obj : class or function
        The object to create a deprecated version of.
    name : string (optional)
        The name of the deprecated object
    message : string (optional)
        The deprecation message

    Returns
    -------
    deprecated_obj :
        The deprecated version of obj

    Examples
    --------
    >>> class Foo(object): pass
    >>> OldFoo = _deprecate(Foo, "OldFoo")
    >>> f = OldFoo()  # doctest: +SKIP
    AltairDeprecationWarning: alt.OldFoo is deprecated. Use alt.Foo instead.
    Nz)alt.{} is deprecated. Use alt.{} instead.__init__)__doc__r   c                     s   t  t | |S )N)warningswarnr   )argskwargsr	   r   r   r   new_obj?   s    z_deprecate.<locals>.new_objz"Cannot deprecate object of type {})formatr   
isinstancetyper   r
   r   callable	functoolswraps
ValueError)r   namer	   r   r   r   r   r
      s$     
r
   )N)NN)r   r   UserWarningr   r   r
   r   r   r   r   <module>   s   
