
    bi|                         d dl Z d dlZd dlZd dlmZ d dlmZmZ ddlm	Z	  e
       a e	e      Zddee   fdZ G d d	e j                         Z G d
 de j$                  e      Zy)    N)wraps)CallableOptional   )
get_loggerhelp_messagec                       dt         f fd}|S )zDecorator to mark a class or a function as deprecated.

    Args:
        help_message (:obj:`str`, optional): An optional message to guide the user on how to
            switch to non-deprecated usage of the library.
    deprecated_class_or_functionc                 ^   t        j                  |       r| j                  | j                  }n3| j                  }|dk7  r|nj                  j                  d      d   }r| dd z   ndt              fd       }d|_        t        j                  |       r	|| _        | S |S )	N__init__.zI is deprecated and will be removed in the next major version of datasets.  c                      t              }|t        vr1t        j                  t        d       t        j                  |        | i |S )N   )category
stacklevel)hash_emitted_deprecation_warningswarningswarnFutureWarningadd)argskwargs	func_hashdeprecated_functionwarning_msgs      [/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/datasets/utils/deprecation_utils.pywrapperz.deprecated.<locals>.decorator.<locals>.wrapper(   sE    01I ==kMaP-11)<&777    
deprecated)inspectisclassr   __name____qualname__splitr   _decorator_name_)r
   namer!   r   r   r   s      @@r    	decoratorzdeprecated.<locals>.decorator   s     ??78">"G"G/88D">&//D:-43F3S3S3Y3YZ]3^_a3bD  f]^cdeqdrass 	 
"	#	8 
$	8 $0 ??784;(1//Nr"   )r   )r   r+   s   ` r    r#   r#      s       D r"   c                   D     e Zd ZdZ fdZ fdZdddddd fdZ xZS )	OnAccessz\
    Enum metaclass that calls a user-specified function whenever a member is accessed.
    c                     t         |   |      }t        |t        j                        r|j
                  r|j                          |S N)super__getattribute__
isinstanceenumEnum
_on_access)clsr*   obj	__class__s      r    r1   zOnAccess.__getattribute__@   s5    g&t,c499%#..NN
r"   c                 ^    t         |   |      }|j                  r|j                          |S r/   )r0   __getitem__r5   )r6   r*   memberr8   s      r    r:   zOnAccess.__getitem__F   s,    $T*r"   Nr   modulequalnametypestartc                    t         |   ||||||      }t        |t        j                        r|j
                  r|j                          |S )Nr<   )r0   __call__r2   r3   r4   r5   )	r6   valuenamesr=   r>   r?   r@   r7   r8   s	           r    rB   zOnAccess.__call__L   sD    gueFXTX`efc499%#..NN
r"   r/   )r&   
__module__r'   __doc__r1   r:   rB   __classcell__)r8   s   @r    r-   r-   ;   s*    4$TYZ  r"   r-   c                   ,    e Zd ZdZd Zed        Zd Zy)DeprecatedEnumzQ
    Enum class that calls `deprecate` method whenever a member is accessed.
    c                 `    t         j                  |       }||_        |j                  |_        |S r/   )object__new___value_	deprecater5   )r6   rC   r;   s      r    rL   zDeprecatedEnum.__new__X   s*    $",,r"   c                      y)Nr    )selfs    r    r   zDeprecatedEnum.help_message^   s    r"   c                     | j                   rd| j                    nd}t        j                  d| j                  j                   d|z   t
        d       y )Nr   r   'zJ' is deprecated and will be removed in the next major version of datasets.   )r   )r   r   r   __objclass__r&   r   )rQ   r   s     r    rN   zDeprecatedEnum.deprecateb   sS    262C2C4,,-.!!**++uv		
r"   N)r&   rE   r'   rF   rL   propertyr   rN   rP   r"   r    rI   rI   S   s%      
r"   rI   )	metaclassr/   )r3   r$   r   	functoolsr   typingr   r   loggingr   setr   r&   loggerstrr#   EnumMetar-   r4   rI   rP   r"   r    <module>r_      s^        %  !$ 	H	*Xc] *Zt}} 0
TYY( 
r"   