a
    �Ï?e«  ã                   @   sÆ   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
 e ¡ dkZejdd… dkZejdd… dkZejdd… dkZd	d
„ ZG dd„ dƒZdd„ Zeƒ Ze ¡ Zdd„ ZdS )é    N)ÚMappingÚSequence)Ú_GenericAliasÚPyPyé   )é   é	   )r   é
   )r   é   c                  O   s   t jdtdd� d S )Nz§Running interpreter doesn't sufficiently support code object introspection.  Some features like bare super() or accessing __class__ will not work with slotted classes.r   )Ú
stacklevel)ÚwarningsÚwarnÚRuntimeWarning)ÚargsÚkw© r   úO/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/attr/_compat.pyÚ	just_warn   s
    ûr   c                   @   s.   e Zd ZdZdgZdd„ Zdd„ Zdd„ Zd	S )
Ú_AnnotationExtractorz^
    Extract type annotations from a callable, returning None whenever there
    is none.
    Úsigc              	   C   s2   zt  |¡| _W n ttfy,   d | _Y n0 d S ©N)ÚinspectÚ	signaturer   Ú
ValueErrorÚ	TypeError)ÚselfÚcallabler   r   r   Ú__init__'   s    z_AnnotationExtractor.__init__c                 C   s>   | j s
dS t| j j ¡ ƒ}|r:|d jtjjur:|d jS dS )zU
        Return the type annotation of the first argument if it's not empty.
        Nr   )r   ÚlistÚ
parametersÚvaluesÚ
annotationr   Ú	ParameterÚempty)r   Úparamsr   r   r   Úget_first_param_type-   s    
z)_AnnotationExtractor.get_first_param_typec                 C   s"   | j r| j jtjjur| j jS dS )z;
        Return the return type if it's not empty.
        N)r   Úreturn_annotationr   Ú	Signaturer#   )r   r   r   r   Úget_return_type:   s    ÿþz$_AnnotationExtractor.get_return_typeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r%   r(   r   r   r   r   r      s
   r   c                     s  t rdd„ } | S zÒtjdkr&dd„ } nŽdd„ }|j}|jdksH|jdkrLt‚|jg}| |j	¡ | 
|j|j|j|j|j|j|j|j|j|j|j|j|jg¡ tj|Ž ‰ ‡ fd	d„} d
d„ }|ƒ jd }| |dƒ |jdkràt‚W n tyø   t Y S 0 | S dS )z|Return a function of two arguments (cell, value) which sets
    the value stored in the closure cell `cell` to `value`.
    c                 S   s   |   |f¡ d S r   )Ú__setstate__©ÚcellÚvaluer   r   r   Úset_closure_cellO   s    z/make_set_closure_cell.<locals>.set_closure_cell)r   é   c                 S   s
   || _ d S r   )Úcell_contentsr/   r   r   r   r2   Y   s    c                    s   | ‰ d S )Nc                      s   ˆ S r   r   r   ©Úxr   r   Úforce_x_to_be_a_celle   s    zQmake_set_closure_cell.<locals>.set_first_cellvar_to.<locals>.force_x_to_be_a_cellr   )r1   r7   r   r5   r   Úset_first_cellvar_to^   s    z3make_set_closure_cell.<locals>.set_first_cellvar_tor5   r   c                    s    t  ˆ i dd| f¡}||ƒ d S )NÚsetterr   )ÚtypesÚFunctionType)r0   r1   r9   ©Zset_first_freevar_coder   r   r2   †   s    ÿc                     s   d ‰ ‡ fdd„} | S )Nc                      s   ˆ S r   r   r   r5   r   r   Úfunc”   s    z@make_set_closure_cell.<locals>.make_func_with_cell.<locals>.funcr   )r=   r   r5   r   Úmake_func_with_cell‘   s    z2make_set_closure_cell.<locals>.make_func_with_cellr   éd   N)ÚPYPYÚsysÚversion_infoÚ__code__Úco_cellvarsÚco_freevarsÚAssertionErrorÚco_argcountÚappendÚco_kwonlyargcountÚextendÚ
co_nlocalsÚco_stacksizeÚco_flagsÚco_codeÚ	co_constsÚco_namesÚco_varnamesÚco_filenameÚco_nameÚco_firstlinenoÚ	co_lnotabr:   ÚCodeTypeÚ__closure__r4   Ú	Exceptionr   )r2   r8   Úcor   r>   r0   r   r<   r   Úmake_set_closure_cellG   sL    

òÿ



rZ   c                 C   s   | j tu r| jS dS )zDIf this is a generic class (A[str]), return the generic base for it.N)Ú	__class__r   Ú
__origin__)Zclr   r   r   Úget_generic_baseµ   s    
r]   )r   ÚplatformrA   Ú	threadingr:   r   Úcollections.abcr   r   Útypingr   Úpython_implementationr@   rB   ZPY_3_9_PLUSZPY310ZPY_3_12_PLUSr   r   rZ   r2   ÚlocalZrepr_contextr]   r   r   r   r   Ú<module>   s"   
(]