o
    siu
                     @   sJ   d dl Z d dlZd dlmZ G dd deZd
ddZd
defdd	ZdS )    Nwrapsc                   @   s   e Zd ZdZdS )VisibleDeprecationWarningzVisible deprecation warning.

    By default, python will not show deprecation warnings, so this class
    can be used when a very visible warning is helpful, for example because
    the usage is most likely a user bug.

    N)__name__
__module____qualname____doc__ r	   r	   T/home/ubuntu/.local/lib/python3.10/site-packages/asteroid/utils/deprecation_utils.pyr      s    r   c                    s    fdd}|S )zlDecorator to add deprecation message.

    Args:
        message: Migration steps to be given to users.
    c                    s   t   fdd}|S )Nc                     sR   d u rdnd } j  d j d| d }tj|tdd  | i |S )Nza future releasez
asteroid v.z. has been deprecated and will be removed from z.    )
stacklevel)r   r   warningswarnr   )argskwargs	from_whatwarn_message)funcmessageversionr	   r
   wrapped   s   z3mark_deprecated.<locals>.decorator.<locals>.wrappedr   )r   r   r   r   )r   r
   	decorator   s   
z"mark_deprecated.<locals>.decoratorr	   )r   r   r   r	   r   r
   mark_deprecated   s   r   returnc                 C   s   dd }dd }t || sdS zt|| }W n
 ty    Y dS w ||dd }|dur/|n|| |}||vrCtd| d	|  d
t || sStd| d|  dt|| }|j|juS )a  Check if `method_name` from parent is overridden in `obj`.

    Args:
        method_name (str): Name of the method.
        obj: Instance or class that potentially overrode the method.
        parent: parent class with which to compare. If None, traverse the MRO
            for the first parent that has the method.

    Raises RuntimeError if `parent` is not a parent class and if `parent`
    doesn't have the method. Or, if `parent` was None, that none of the
    potential parents had the method.
    c                 S   s,   zt | W S  ty   t | j Y S w N)inspectgetmroAttributeError	__class__)clsr	   r	   r
   get_mro8   s
   zis_overridden.<locals>.get_mroc                 S   s*   |d d d D ]}t || r|  S qd S )N)hasattr)fnmro_listr!   r	   r	   r
   first_parent_with_method>   s
   
z/is_overridden.<locals>.first_parent_with_methodF   N`z$` has no parent that defined method z`.zParent `z` does have method `)r$   getattrr   RuntimeError__code__)method_nameobjparentr"   r'   instance_attrmro
super_attrr	   r	   r
   is_overridden*   s"   


r3   r   )	r   r   	functoolsr   UserWarningr   r   boolr3   r	   r	   r	   r
   <module>   s    
