
    G/Ph	                       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
	 d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<   n# e$ rZeZY dZ[ndZ[ww xY wg Zded<   d.dZd/dZd0dZ e            Z ded<    e            Z!ded<    e            Z"ded<   d1dZ#esed2d Z$d3d'Z% G d( d)e          Z&d4d,Z'dS d4d-Z'dS )5a  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: https://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                    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dt           j        fg} i }| D ](\  }}d |            j        j        z  }d| d|d| <   )|S )N	_NBitByte
_NBitShort	_NBitIntC	_NBitIntP_NBitInt	_NBitLong_NBitLongLong	_NBitHalf_NBitSingle_NBitDouble_NBitLongDouble   znumpy._Bitnumpy._typing._nbit.)npbyteshortintcintpint_longlonglonghalfsingledouble
longdoubledtypeitemsize)namesretnametypns        X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpy/typing/mypy_plugin.py_get_precision_dictr7   8   s    	bg	rx 	bg	bg	RW	bg	"+&	bg		"		"	BM*E C > >	cSSUU[))-=q-=-=-=)4))**J    c                 "    g d} d | D             S )N)uint128uint256int128int256float80float96float128float256
complex160
complex192
complex256
complex512c                <    g | ]}t          t          |          |S  )hasattrr#   ).0is     r6   
<listcomp>z0_get_extended_precision_list.<locals>.<listcomp>]   s%    888!Q8A888r8   rG   )extended_namess    r6   _get_extended_precision_listrM   N   s)      N 98~8888r8   strc                 h    t          j        d          j        } | dk    rdS | dk    rdS | dk    rdS dS )Nr5   rJ   c_intlc_longq
c_longlong)r#   r/   char)rU   s    r6   _get_c_intp_namerV   `   sA    8C==Ds{{w	x	|xr8   r   _PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTPctxr
   r   c                    | \  }}}|j                             d          d         }t          d|          }|                    |          S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..r"   )r3   splitrW   
named_type)rZ   r4   _apir3   name_news         r6   _hookrc   x   sJ    KCC8>>#r"D<d<<=H>>(###r8   iterableIterable[Statement]idintc                    t          |           D ]\  }}t          |dd          |k    r|c S t          d|          )z>Identify the first ``ImportFrom`` instance the specified `id`.rf   NzBFailed to identify a `ImportFrom` instance with the following id: )	enumerategetattr
ValueError)rd   rf   rJ   values       r6   _indexrm      sf    !(++ 	 	HAuudD))R// 0 :35: : ; ; 	;r8   filer   moduleimportslist[tuple[str, None | str]]Nonec                    t          |d|          }d|_        | j        | j        fD ]}t	          ||          }|||<   dS )z<Override the first `module`-based import with new `imports`.r   )r1   TN)r   is_top_leveldefsrp   rm   )rn   ro   rp   
import_objlstrJ   s         r6   _override_importsrx      s^      999
"&
 It|, 	  	 CsF##ACFF	  	 r8   c                  "    e Zd ZdZddZdd
ZdS )_NumpyPluginz>A mypy plugin for handling versus numpy-specific typing tasks.fullnamerN   r   None | _HookFuncc                &    |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)rW   rc   )selfr{   s     r6   get_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hook   s     ?**4r8   rn   r   list[tuple[int, str, int]]c                    t           |j        dfg}|j        dk    r"t          |dd t          D                        n%|j        dk    rt          |dt          dfg           |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`.

            r]   numpyz!numpy._typing._extended_precisionc                    g | ]}||fS rG   rG   )rI   vs     r6   rK   z4_NumpyPlugin.get_additional_deps.<locals>.<listcomp>   s    FFFaVFFFr8   )rp   znumpy.ctypeslibctypes_c_intp)r   r{   rx   rX   rY   )r~   rn   r2   s      r6   get_additional_depsz _NumpyPlugin.get_additional_deps   s     T]B/0C}''!=FF-EFFF     "333!(%y12    Jr8   N)r{   rN   r   r|   )rn   r   r   r   )__name__
__module____qualname____doc__r   r   rG   r8   r6   rz   rz      sB        LL	 	 	 		 	 	 	 	 	r8   rz   versiontype[_NumpyPlugin]c                    t           S zAn entry-point for mypy.)rz   r   s    r6   pluginr      s    r8   c                    t           r   )r   r   s    r6   r   r      s    r8   )r   r   )r   r   )r   rN   )rZ   r
   r   r   )rd   re   rf   rN   r   rg   )rn   r   ro   rN   rp   rq   r   rr   )r   rN   r   r   )(r   
__future__r   collections.abcr   typingr   r   r   r   r#   
mypy.typesmypyr   mypy.pluginr	   r
   
mypy.nodesr   r   r   
mypy.buildr   	_HookFuncr   __annotations__ModuleNotFoundErrorexr   r7   rM   rV   rW   rX   rY   rc   rm   rx   rz   r   rG   r8   r6   <module>r      s{    B # " " " " " $ $ $ $ $ $ 1 1 1 1 1 1 1 1 1 1    
66666666::::::::::"""""",-t34I*.G.....   GGGGGG        ,9 9 9 9$
 
 
 
 -,.. . . . . #?">"@"@  @ @ @ @ "!## # # # #$ $ $ $  EGO; ; ; ;       $ $ $ $ $v $ $ $L     
     s   4A A%A  A%