U
    j7g                     @   sH  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ejdd d	kZejdd d
kZejdd dkZejdd dkZejdk rzd dlmZ W n ek
r   eZY nX nd dlmZ erd dlZejZndd ZG dd dZe Zdd ZdS )    N)MappingSequence)_GenericAliasPyPy   )      )r   	   )r   
   )r      )r      )r      )r      )Protocolc                 C   s   | j di S )z,
        Get annotations for *cls*.
        __annotations__)__dict__get)cls r   0/tmp/pip-unpacked-wheel-jjqst275/attr/_compat.py_get_annotations%   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   zt || _W n ttfk
r.   d | _Y nX d S )N)inspect	signaturer   
ValueError	TypeError)selfcallabler   r   r   __init__4   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_typeG   s    z$_AnnotationExtractor.get_return_typeN)__name__
__module____qualname____doc__	__slots__r   r'   r*   r   r   r   r   r   ,   s
   r   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__)Zclr   r   r   get_generic_basec   s    
r2   )r   platformsys	threadingcollections.abcr   r   typingr   python_implementationZPYPYversion_infoZPY_3_8_PLUSZPY_3_9_PLUSZPY_3_10_PLUSZPY_3_11_PLUSZPY_3_12_PLUSZPY_3_13_PLUSZPY_3_14_PLUSZtyping_extensionsr   ImportErrorobjectZannotationlibZget_annotationsr   r   localZrepr_contextr2   r   r   r   r   <module>   s4   
4