B
    4d                 @   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 )NzRunning 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   Y/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/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   s4   yt || _W n ttfk
r.   d | _Y nX 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k	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k	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 ytjdkr&dd } nd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rtW n tk
r   tS X | 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 )N)__setstate__)cellvaluer   r   r   set_closure_cellO   s    z/make_set_closure_cell.<locals>.set_closure_cell)r      c             S   s
   || _ d S )N)cell_contents)r.   r/   r   r   r   r0   Y   s    c                s   |  d S )Nc                  s    S )Nr   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   )r/   r4   r   )r3   r   set_first_cellvar_to^   s    z3make_set_closure_cell.<locals>.set_first_cellvar_to)r3   r   c                s    t  i dd| f}|| d S )Nsetterr   )typesFunctionType)r.   r/   r6   )set_first_freevar_coder   r   r0      s    c                 s   d   fdd} | S )Nc                  s    S )Nr   r   )r3   r   r   func   s    z@make_set_closure_cell.<locals>.make_func_with_cell.<locals>.funcr   )r:   r   )r3   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_lnotabr7   CodeType__closure__r2   	Exceptionr   )r0   r5   cor   r;   r.   r   )r9   r   make_set_closure_cellG   sH    





rW   c             C   s   | j tkr| jS dS )zDIf this is a generic class (A[str]), return the generic base for it.N)	__class__r   
__origin__)clr   r   r   get_generic_base   s    
r[   )r   platformr>   	threadingr7   r   collections.abcr   r   typingr   python_implementationr=   r?   ZPY_3_9_PLUSZPY310ZPY_3_12_PLUSr   r   rW   r0   localZrepr_contextr[   r   r   r   r   <module>   s"   
(]