
    uhh              
       \   U d Z ddlmZmZ ddlmZmZmZmZ ddl	Z
g Zee         ed<   deeef         fdZdee         fdZdefd	Zd
Zeed<    e            Zeed<    e            Zeed<    e            Zeed<   	 erddlmZ ddlZddlmZ ddlmZmZm Z  ddl!m"Z"m#Z# ee"gej$        j%        f         Z&eed<   de"dej$        j%        fdZ'dee          dede(fdZ)dededee*eedz  f                  ddfdZ+ G d de#          Z,dede-fd Z.dS # e/$ rZ0dede-fd!Z.Y dZ0[0dS dZ0[0w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

.. deprecated:: 2.3

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

    )CallableIterable)TYPE_CHECKINGFinal	TypeAliascastN__all__returnc                     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t          j        |          j        z  }t           d| d|t           d| <   <|S )N	_NBitByte
_NBitShort	_NBitIntC	_NBitIntP_NBitInt	_NBitLong_NBitLongLong	_NBitHalf_NBitSingle_NBitDouble_NBitLongDouble   z._nbit_base._Bit._nbit.)npbyteshortintcintpint_longlonglonghalfsingledouble
longdoubledtypeitemsize_MODULE)namesretnametypns        O/var/www/histauto/venv/lib/python3.11/site-packages/numpy/typing/mypy_plugin.py_get_precision_dictr/   ,   s    	bg	rx 	bg	bg	RW	bg	"+&	bg		"		"	BM*E C I I	c&&,3)H)H!)H)H)Hw%%t%%&&J    c                  "    g d} d | D             S )N)float96float128
complex192
complex256c                 <    g | ]}t          t          |          |S  )hasattrr   ).0is     r.   
<listcomp>z0_get_extended_precision_list.<locals>.<listcomp>I   s%    888!Q8A888r0   r7   )extended_namess    r.   _get_extended_precision_listr=   B   s)      N 98~8888r0   c                  d    dddd                     t          j        d          j        d          S )Nc_intc_long
c_longlong)r:   lqr-   )getr   r&   charr7   r0   r.   _get_c_intp_namerF   K   s8       
c"(3--
h''	(r0   znumpy._typingr(   _PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTP)TypeAnalyser)PRI_MED)
ImportFromMypyFile	Statement)AnalyzeTypeContextPlugin	_HookFuncctxc                     | \  }}}|j                             d          d         }t          t           d|          }t	          d|                              |          S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..r   rJ   )r+   splitrG   r(   r   
named_type)rR   r,   _apir+   name_news         r.   _hookr[   s   s[    Qx~~c""2&"g#<#<d#<#<=NC((33H===r0   iterableidc                     t          |           D ]\  }}t          |dd          |k    r|c S t          d|          )z>Identify the first ``ImportFrom`` instance the specified `id`.r]   NzBFailed to identify a `ImportFrom` instance with the following id: )	enumerategetattr
ValueError)r\   r]   r:   values       r.   _indexrc   z   sf    !(++ 	 	HAuudD))R// 0 :35: : ; ; 	;r0   filemoduleimportsc                     t          |d|          }d|_        | j        t          d| j                  fD ]}t          ||          }|||<   dS )z<Override the first `module`-based import with new `imports`.r   )r)   Tzlist[Statement]N)rL   is_top_leveldefsr   rf   rc   )rd   re   rf   
import_objlstr:   s         r.   _override_importsrl      si      999
"&
 It$5t|DDE 	  	 CsF##ACFF	  	 r0   c                   V    e Zd ZdZdededz  fdZdedee	e
ee
f                  fdZdS )_NumpyPluginz>A mypy plugin for handling versus numpy-specific typing tasks.fullnamer
   Nc                 &    |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)rG   r[   )selfro   s     r.   get_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hook   s     ?**4r0   rd   c                     |j         }|dk    r*t          |t           dd t          D                        n |dk    rt          |dt          dfg           t
          |dfgS )	a  Handle all import-based overrides.

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

            numpyz._extended_precisionc                     g | ]}||fS r7   r7   )r9   vs     r.   r;   z4_NumpyPlugin.get_additional_deps.<locals>.<listcomp>   s    FFFaVFFFr0   )rf   znumpy.ctypeslibctypes_c_intprU   )ro   rl   r(   rH   rI   rK   )rq   rd   ro   s      r.   get_additional_depsz _NumpyPlugin.get_additional_deps   s     }H7""!444FF-EFFF    
 ...!%y12   
 h+,,r0   )__name__
__module____qualname____doc__strrQ   rr   rM   listtupleintry   r7   r0   r.   rn   rn      su        LL	# 	)d:J 	 	 	 		- 	-%S#&'	- 	- 	- 	- 	- 	-r0   rn   versionc                 h    dd l }d}d| d| d}|                    |t          d           t          S )Nr   znumpy.typing.mypy_plugin`zS` is deprecated, and will be removed in a future release. Please remove `plugins = z/` in your mypy config.(deprecated in NumPy 2.3)   )
stacklevel)warningswarnDeprecationWarningrn   )r   r   pluginwarn_msgs       r.   r   r      sY    +) ) )17) ) ) 	
 	h 2qAAAr0   c                     t           )N)e)r   s    r.   r   r   l   s    r0   )1r}   collections.abcr   r   typingr   r   r   r   rt   r   r	   r   r~   __annotations__dictr/   r=   rF   r(   rG   rH   rI   mypy.typeanalrJ   
mypy.typesmypy
mypy.buildrK   
mypy.nodesrL   rM   rN   mypy.pluginrO   rP   typesTyperQ   r[   r   rc   r   rl   rn   typer   ModuleNotFoundErrorr   r7   r0   r.   <module>r      s$  ! ! !F / . . . . . . . 8 8 8 8 8 8 8 8 8 8 8 8    c   T#s(^    ,9d3i 9 9 9 9(# ( ( ( ( !       -,.. . . . #?">"@"@ % @ @ @ "!## # # #b /......""""""::::::::::66666666 $%7$8$*/$IJIyJJJ>% >$*/ > > > >;), ;# ;# ; ; ; ;    eCtO,-  
	       $- $- $- $- $-v $- $- $-L       [               s   >$D D+D&&D+