
    {h-i                       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<   g Zded<   ddZddZddZ e       Z ded<    e       Z!ded<    e       Z"ded<   ddZ#ese d dZ$	 	 	 	 	 	 	 	 d!dZ% G d de      Z&d"dZ'yd"dZ'y# e$ rZeZY dZ[pdZ[ww xY w)#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__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g
} i }| D ]/  \  }}d |       j                  j                  z  }d| d|d| <   1 |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ns        WD:\DhanshreeandTeamAI\Github\ai_code\venv\Lib\site-packages\numpy/typing/mypy_plugin.py_get_precision_dictr3   8   s    	bgg	rxx 	bgg	bgg	RWW	"++&	bgg			"			"	BMM*E C	cSU[[)))/6qc-="4&)*  J    c                 V    g d} | D cg c]  }t        t        |      s| c}S c c}w )N)uint128uint256int128int256float80float96float128float256
complex160
complex192
complex256
complex512)hasattrr    )extended_namesis     r2   _get_extended_precision_listrE   M   s+    N &8~!QA~888s   &&c                 f    t        j                  d      j                  } | dk(  ry| dk(  ry| dk(  ryy)NprD   c_intlc_longq
c_longlong)r    r+   char)rM   s    r2   _get_c_intp_namerN   _   s6    88C=Ds{		r4   r   _PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTPc                    | \  }}}|j                   j                  d      d   }t        d|    }|j                  |      S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..r   )r/   splitrO   
named_type)ctxr0   _apir/   name_news         r2   _hookr[   w   sE    KCC88>>#r"D!5dV<=H>>(##r4   c                l    t        |       D ]  \  }}t        |dd      |k(  s|c S  t        d|      )z>Identify the first ``ImportFrom`` instance the specified `id`.idNzBFailed to identify a `ImportFrom` instance with the following id: )	enumerategetattr
ValueError)iterabler]   rD   values       r2   _indexrc      sI    !(+HAuudD)R/ ,  335&: ; 	;r4   c                    t        |d|      }d|_        | j                  | j                  fD ]  }t	        ||      }|||<    y)z<Override the first `module`-based import with new `imports`.r   )r-   TN)r   is_top_leveldefsimportsrc   )filemodulerg   
import_objlstrD   s         r2   _override_importsrl      sH      9
"&
 IIt||,CsF#ACF -r4   c                  (    e Zd ZdZddZ	 	 	 	 ddZy)_NumpyPluginz>A mypy plugin for handling versus numpy-specific typing tasks.c                     |t         v rt        S y)zSet the precision of platform-specific `numpy.number`
            subclasses.

            For example: `numpy.int_`, `numpy.longlong` and `numpy.longdouble`.
            N)rO   r[   )selffullnames     r2   get_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hook   s     ?*r4   c           	         t         |j                  dfg}|j                  dk(  r$t        |dt        D cg c]  }||f c}       |S |j                  dk(  rt        |dt        dfg       |S c c}w )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`.

            rT   numpyz!numpy._typing._extended_precision)rg   znumpy.ctypeslibctypes_c_intp)r   rq   rl   rP   rQ   )rp   rh   r.   vs       r2   get_additional_depsz _NumpyPlugin.get_additional_deps   s     T]]B/0C}}'!=-EF-EaV-EF J "33!(%y12 J Gs   A.N)rq   strreturnzNone | _HookFunc)rh   r   rz   zlist[tuple[int, str, int]])__name__
__module____qualname____doc__rr   rx    r4   r2   rn   rn      s    L		 	'	r4   rn   c                    t         S zAn entry-point for mypy.)rn   versions    r2   pluginr      s    r4   c                    t         r   )r   r   s    r2   r   r      s    r4   )rz   zdict[str, str])rz   r   )rz   ry   )rW   r
   rz   r   )ra   zIterable[Statement]r]   ry   rz   int)rh   r   ri   ry   rg   zlist[tuple[str, None | str]]rz   None)r   ry   rz   ztype[_NumpyPlugin])(r~   
__future__r   collections.abcr   typingr   r   r   rt   r    
mypy.typesmypyr   mypy.pluginr	   r
   
mypy.nodesr   r   r   
mypy.buildr   	_HookFuncr   __annotations__ModuleNotFoundErrorexr   r3   rE   rN   rO   rP   rQ   r[   rc   rl   rn   r   r   r4   r2   <module>r      s  B # $ 1 1 
6::",-t34I*.G'.  *9$
 -. . #?"@ % @ "# #$ GO;    .  
	 $v $L
a  Gs   1B4 4C9C  C