o
    dO                  
   @  sp  U d Z ddlmZ ddlmZ ddlmZmZmZ ddl	Z
z1d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egef ZdZd
ed< W n eyb Z zeZW Y dZ[ndZ[ww g Zded< d5ddZd6ddZd7ddZe Z ded< e Z!ded< e Z"ded< d8ddZ#esedu rd9d$d%Z$d:d,d-Z%G d.d/ d/eZ&d;d2d3Z'dS d;d4d3Z'dS )<a  A mypy_ plugin for managing a number of platform-specific annotations.
Its functionality can be split into three distinct parts:

* Assigning the (platform-dependent) precisions of certain `~numpy.number`
  subclasses, including the likes of `~numpy.int_`, `~numpy.intp` and
  `~numpy.longlong`. See the documentation on
  :ref:`scalar types <arrays.scalars.built-in>` for a comprehensive overview
  of the affected classes. Without the plugin the precision of all relevant
  classes will be inferred as `~typing.Any`.
* Removing all extended-precision `~numpy.number` subclasses that are
  unavailable for the platform in question. Most notably this includes the
  likes of `~numpy.float128` and `~numpy.complex256`. Without the plugin *all*
  extended-precision types will, as far as mypy is concerned, be available
  to all platforms.
* Assigning the (platform-dependent) precision of `~numpy.ctypeslib.c_intp`.
  Without the plugin the type will default to `ctypes.c_int64`.

  .. versionadded:: 1.22

Examples
--------
To enable the plugin, one must add it to their mypy `configuration file`_:

.. code-block:: ini

    [mypy]
    plugins = numpy.typing.mypy_plugin

.. _mypy: http://mypy-lang.org/
.. _configuration file: https://mypy.readthedocs.io/en/stable/config_file.html

    )annotations)Iterable)FinalTYPE_CHECKINGCallableN)Type)PluginAnalyzeTypeContext)MypyFile
ImportFrom	Statement)PRI_MEDzNone | ModuleNotFoundErrorMYPY_EX	list[str]__all__returndict[str, str]c                  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 }| D ]\}}d| jj }d| d|d| < q.|S )N	_NBitByte
_NBitShort	_NBitIntC	_NBitIntP_NBitInt_NBitLongLong	_NBitHalf_NBitSingle_NBitDouble_NBitLongDouble   znumpy._Bitnumpy._typing._nbit.)npbyteshortintcintpint_longlonghalfsingledouble
longdoubledtypeitemsize)namesretnametypn r2   ]/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/numpy/typing/mypy_plugin.py_get_precision_dict8   s    r4   c                    s.   t jt jt jt jg} h d  fdd| D S )N>   int128int256float80float96uint128uint256float128float256
complex160
complex192
complex256
complex512c                   s   g | ]
}|j  v r|j qS r2   )__name__).0iextended_namesr2   r3   
<listcomp>]   s    z0_get_extended_precision_list.<locals>.<listcomp>)r    	ulonglongr&   r*   clongdouble)extended_typesr2   rD   r3   _get_extended_precision_listM   s   rJ   strc                  C  s4   t dj} | dkrdS | dkrdS | dkrdS dS )NprC   c_intlc_longq
c_longlong)r    r+   char)rR   r2   r2   r3   _get_c_intp_name`   s   rS   r   _PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTPctxr	   r   c                 C  s2   | \}}}|j dd }td|  }||S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..r   )r/   splitrT   
named_type)rW   r0   _apir/   name_newr2   r2   r3   _hookx   s   

r_   iterableIterable[Statement]idintc                 C  s8   t | D ]\}}t|dd|kr|  S qtd|)z>Identify the first ``ImportFrom`` instance the specified `id`.rb   NzBFailed to identify a `ImportFrom` instance with the following id: )	enumerategetattr
ValueError)r`   rb   rC   valuer2   r2   r3   _index   s   rh   filer
   moduleimportslist[tuple[str, None | str]]Nonec                 C  s<   t |d|d}d|_| j| jfD ]}t||}|||< qdS )z<Override the first `module`-based import with new `imports`.r   )r-   TN)r   is_top_leveldefsrk   rh   )ri   rj   rk   
import_objlstrC   r2   r2   r3   _override_imports   s   

rr   c                   @  s$   e Zd ZdZdddZdddZdS )_NumpyPluginz>A mypy plugin for handling versus numpy-specific typing tasks.fullnamerK   r   None | _HookFuncc                 C  s   |t v rtS dS )zSet the precision of platform-specific `numpy.number`
            subclasses.

            For example: `numpy.int_`, `numpy.longlong` and `numpy.longdouble`.
            N)rT   r_   )selfrt   r2   r2   r3   get_type_analyze_hook   s   z"_NumpyPlugin.get_type_analyze_hookri   r
   list[tuple[int, str, int]]c                 C  sV   t |jdfg}|jdkrt|ddd tD d |S |jdkr)t|dtd	fgd |S )
a.  Handle all import-based overrides.

            * Import platform-specific extended-precision `numpy.number`
              subclasses (*e.g.* `numpy.float96`, `numpy.float128` and
              `numpy.complex256`).
            * Import the appropriate `ctypes` equivalent to `numpy.intp`.

            rY   numpyz!numpy._typing._extended_precisionc                 S  s   g | ]}||fqS r2   r2   )rB   vr2   r2   r3   rF      s    z4_NumpyPlugin.get_additional_deps.<locals>.<listcomp>)rk   znumpy.ctypeslibctypes_c_intp)r   rt   rr   rU   rV   )rv   ri   r.   r2   r2   r3   get_additional_deps   s   
	
z _NumpyPlugin.get_additional_depsN)rt   rK   r   ru   )ri   r
   r   rx   )rA   
__module____qualname____doc__rw   r}   r2   r2   r2   r3   rs      s    

rs   versiontype[_NumpyPlugin]c                 C  s   t S zAn entry-point for mypy.)rs   r   r2   r2   r3   plugin      r   c                 C  s   t r   )r   r   r2   r2   r3   r      r   )r   r   )r   r   )r   rK   )rW   r	   r   r   )r`   ra   rb   rK   r   rc   )ri   r
   rj   rK   rk   rl   r   rm   )r   rK   r   r   )(r   
__future__r   collections.abcr   typingr   r   r   ry   r    
mypy.typesmypyr   mypy.pluginr   r	   
mypy.nodesr
   r   r   
mypy.buildr   	_HookFuncr   __annotations__ModuleNotFoundErrorexr   r4   rJ   rS   rT   rU   rV   r_   rh   rr   rs   r   r2   r2   r2   r3   <module>   s>    !





&