B
    .uf8              
   @  s\  U d Z ddlmZ ddlZddlZydddlZddlm	Z	 ddl
mZmZ ddlmZmZmZ ddlmZ ejege	f ZdZded	< W n& ek
r Z zeZW ddZ[X Y nX g Zd
ed< ddddZd
dddZe Zded< e Zded< dddddZejsedkrHddddddZ G d d! d!eZ!dd"d#d$d%Z"ndd"d#d&d%Z"dS )'z6A module containing `numpy`-specific plugins for mypy.    )annotationsN)Type)PluginAnalyzeTypeContext)MypyFile
ImportFrom	Statement)PRI_MEDzt.Optional[ModuleNotFoundError]MYPY_EXzt.List[str]__all__zt.Dict[str, str])returnc              C  s   dt jfdt jfdt jfdt jfdt jfdt jfdt jfdt jfd	t j	fd
t j
fg
} i }x4| D ],\}}d| jj }d| d|d| < q^W |S )NZ	_NBitByteZ
_NBitShortZ	_NBitIntCZ	_NBitIntPZ_NBitIntZ_NBitLongLongZ	_NBitHalfZ_NBitSingleZ_NBitDoubleZ_NBitLongDouble   znumpy._ZBitznumpy.typing._nbit.)npbyteshortZintcZintpint_longlongZhalfZsingledouble
longdoubleZdtypeitemsize)namesretnametypn r   Z/home/ankuromar296_gmail_com/myenv/lib/python3.7/site-packages/numpy/typing/mypy_plugin.py_get_precision_dict   s    r   c                sB   t jt jt jt jg} ddddddddd	d
ddh  fdd| D S )NZuint128Zuint256Zint128Zint256Zfloat80Zfloat96Zfloat128Zfloat256Z
complex160Z
complex192Z
complex256Z
complex512c               s   g | ]}|j  kr|j qS r   )__name__).0i)extended_namesr   r   
<listcomp>=   s    z0_get_extended_precision_list.<locals>.<listcomp>)r   Z	ulonglongr   r   Zclongdouble)Zextended_typesr   )r!   r   _get_extended_precision_list-   s    r#   zt.Final_PRECISION_DICT_EXTENDED_PRECISION_LISTr   r   )ctxr   c             C  s2   | \}}}|j dd }td|  }||S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..znumpy.typing._nbit.)r   splitr$   Z
named_type)r&   r   _apir   Zname_newr   r   r   _hookH   s    
r,   zt.Iterable[Statement]strint)iterableidr   c             C  s<   x6t | D ]\}}t|dd|kr
|S q
W td|dS )z>Identify the first ``ImportFrom`` instance the specified `id`.r0   NzBFailed to identify a `ImportFrom` instance with the following id: )	enumerategetattr
ValueError)r/   r0   r    valuer   r   r   _indexQ   s    r5   c               @  s0   e Zd ZdZdddddZddd	d
dZdS )_NumpyPluginzCA plugin for assigning platform-specific `numpy.number` precisions.r-   zt.Optional[_HookFunc])fullnamer   c             C  s   |t krtS dS )zSet the precision of platform-specific `numpy.number` subclasses.

            For example: `numpy.int_`, `numpy.longlong` and `numpy.longdouble`.
            N)r$   r,   )selfr7   r   r   r   get_type_analyze_hook]   s    z"_NumpyPlugin.get_type_analyze_hookr   zt.List[t.Tuple[int, str, int]])filer   c             C  sb   t |jdfg}|jdkr^tdddd tD d}d|_x&|j|jgD ]}t|d}|||< qDW |S )	zImport platform-specific extended-precision `numpy.number` subclasses.

            For example: `numpy.float96`, `numpy.float128` and `numpy.complex256`.
            r(   numpyz numpy.typing._extended_precisionr   c             S  s   g | ]}||fqS r   r   )r   vr   r   r   r"   q   s    z4_NumpyPlugin.get_additional_deps.<locals>.<listcomp>)r   T)r	   r7   r   r%   Zis_top_levelZdefsimportsr5   )r8   r:   r   r=   lstr    r   r   r   get_additional_depsf   s    

z _NumpyPlugin.get_additional_depsN)r   
__module____qualname____doc__r9   r?   r   r   r   r   r6   Z   s   	r6   zt.Type[_NumpyPlugin])versionr   c             C  s   t S )zAn entry-point for mypy.)r6   )rC   r   r   r   plugin|   s    rD   c             C  s   t dS )zAn entry-point for mypy.N)r
   )rC   r   r   r   rD      s    )#rB   
__future__r   typingtr;   r   Z
mypy.typesZmypyr   Zmypy.pluginr   r   Z
mypy.nodesr   r   r   Z
mypy.buildr	   CallableZ	_HookFuncr
   __annotations__ModuleNotFoundErrorexr   r   r#   r$   r%   r,   TYPE_CHECKINGr5   r6   rD   r   r   r   r   <module>   s0   	"