
    j}gF                       U d Z ddlmZ ddlmZmZmZ ddlZerddl	m
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)FinalTYPE_CHECKINGCallableN)Iterable)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 ],\  }}d |            j        j        z  }| d| d|| d| <   -|S )N	_NBitByte
_NBitShort	_NBitIntC	_NBitIntP_NBitInt	_NBitLong_NBitLongLong	_NBitHalf_NBitSingle_NBitDouble_NBitLongDoubleznumpy._typing   z._nbit_base._Bitz._nbit.)npbyteshortintcintpint_longlonglonghalfsingledouble
longdoubledtypeitemsize)namesretmodulenametypns         X/var/www/py-google-trends/myenv/lib/python3.11/site-packages/numpy/typing/mypy_plugin.py_get_precision_dictr7   :   s    	bg	rx 	bg	bg	RW	bg	"+&	bg		"		"	BM*E CF G G	cSSUU[))+1(F(F(F(F(Fv$$d$$%%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   Q   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   b   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..znumpy._typing._nbit.)r3   splitrW   
named_type)rZ   r4   _apir3   name_news         r6   _hookrc   z   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   r2   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   )r0   TN)r   is_top_leveldefsro   rm   )rn   r2   ro   
import_objlstrJ   s         r6   _override_importsrw      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   )selfrz   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   )ro   znumpy.ctypeslibctypes_c_intp)r   rz   rw   rX   rY   )r}   rn   r1   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)rz   rN   r   r{   )rn   r   r   r   )__name__
__module____qualname____doc__r~   r   rG   r8   r6   ry   ry      sB        LL	 	 	 		 	 	 	 	 	r8   ry   versiontype[_NumpyPlugin]c                    t           S zAn entry-point for mypy.)ry   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   r2   rN   ro   rp   r   rq   )r   rN   r   r   )(r   
__future__r   typingr   r   r   r   r"   collections.abcr   
mypy.typesmypyr   mypy.pluginr	   r
   
mypy.nodesr   r   r   
mypy.buildr   	_HookFuncr   __annotations__ModuleNotFoundErrorexr   r7   rM   rV   rW   rX   rY   rc   rm   rw   ry   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'