
    C>qj              
          U d Z ddlmZmZ ddl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" ddd fZ#de!dejH                  jJ                  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-y# e.$ rZ/d ede,fd"Z-Y dZ/[/ydZ/[/ww xY w)#aK  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
    The :mod:`numpy.typing.mypy_plugin` entry-point is deprecated in favor of
    platform-agnostic static type inference. Remove
    ``numpy.typing.mypy_plugin`` from the ``plugins`` section of your mypy
    configuration; if that surfaces new errors, please open an issue with a
    minimal reproducer.

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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| <   A |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        W/opt/rentech/trading_bot/.venv/lib/python3.12/site-packages/numpy/typing/mypy_plugin.py_get_precision_dictr.   1   s    	bgg	rxx 	bgg	bgg	RWW	bgg	"++&	bgg			"			"	BMM*E C I	c&&&,39M!C)Hwiwtf%&I J    c                  V    g d} | D cg c]  }t        t        |      s| c}S c c}w )N)float96float128
complex192
complex256)hasattrr   )extended_namesis     r-   _get_extended_precision_listr8   G   s'    N &8!QA888s   &&c                  h    ddddj                  t        j                  d      j                  d      S )Nc_intc_long
c_longlong)r7   lqr,   )getr   r%   char r/   r-   _get_c_intp_namerB   P   s3      
c"((3-

h'	(r/   znumpy._typingr'   _PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTP)TypeAnalyser)PRI_MED)
ImportFromMypyFile	Statement)AnalyzeTypeContextPlugin	_HookFuncc                  R    t         t        gt        j                  j                  f   S N)r   rK   mypytypesTyperA   r/   r-   rM   rM   v   s    X12DJJOOCDDr/   ctxc                     | \  }}}|j                   j                  d      d   }t        t         d|    }t	        d|      j                  |      S )z;Replace a type-alias with a concrete ``NBitBase`` subclass..r   rF   )r*   splitrC   r'   r   
named_type)rS   r+   _apir*   name_news         r-   _hookr\   x   sQ    Qxx~~c"2&"gYgdV#<=NC(33H==r/   iterableidc                 l    t        |       D ]  \  }}t        |dd      |k(  s|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^   r7   values       r-   _indexrd      sN    !(+ 	HAuudD)R/	  335&: ; 	;r/   filemoduleimportsc                     t        |d|      }d|_        | j                  t        d| j                        fD ]  }t        ||      }|||<    y)z<Override the first `module`-based import with new `imports`.r   )r(   Tzlist[Statement]N)rH   is_top_leveldefsr   rg   rd   )re   rf   rg   
import_objlstr7   s         r-   _override_importsrm      sU      9
"&
 IIt$5t||DE 	 CsF#ACF	 r/   c                   H    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y)_NumpyPluginz>A mypy plugin for handling versus numpy-specific typing tasks.fullnamer	   Nc                      |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)rC   r\   )selfrp   s     r-   get_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hook   s     ?*r/   re   c           	          |j                   }|dk(  r*t        |t         dt        D cg c]  }||f c}       n|dk(  rt        |dt        dfg       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` and `numpy.float128`).
            * Import the appropriate `ctypes` equivalent to `numpy.intp`.

            numpyz._extended_precision)rg   znumpy.ctypeslibctypes_c_intprV   )rp   rm   r'   rD   rE   rG   )rr   re   rp   vs       r-   get_additional_depsz _NumpyPlugin.get_additional_deps   sy     }}H7"!i34-EFaVF
 ..!%y12
 h+,, Gs   A )__name__
__module____qualname____doc__strrM   rs   rI   listtupleintry   rA   r/   r-   ro   ro      sB    L	# 	)d:J 		- 	-%S#&'	-r/   ro   versionc                 \    dd l }d}d| d| d}|j                  |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DeprecationWarningro   )r   r   pluginwarn_msgs       r-   r   r      sG    + x 117 9() 	
 	h 2qAr/   c                     t         rO   )_exc)r   s    r-   r   r   q   s    
r/   )0r}   collections.abcr   r   typingr   r   r   ru   r   r   r   r~   __annotations__dictr.   r8   rB   r'   rC   rD   rE   mypy.typeanalrF   
mypy.typesrP   
mypy.buildrG   
mypy.nodesrH   rI   rJ   mypy.pluginrK   rL   rM   rQ   rR   r\   r   rd   r   rm   ro   typer   ModuleNotFoundErrorr   rA   r/   r-   <module>r      ss  &P / - - c T#s(^ ,9d3i 9(# ( !   -. . #?"@ % @ "# #b."::6 E>% >$**// >;), ;# ;# ;    eCtO,-  
	 $-v $-L  [     s   *$C) )D .C;;D 