§
    €ÛgO  ã                  ó¤  — 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: 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__Úreturnúdict[str, str]c                 óh  — 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Ú_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        úN/granary/edev/quantum/lib/python3.11/site-packages/numpy/typing/mypy_plugin.pyÚ_get_precision_dictr5   8   sÂ   € à	•b”gÐØ	•r”xÐ Ø	•b”gÐØ	•b”gÐØ	•R”WÐØ	�"œ+Ð&à	•b”gÐØ	�œ	Ð"Ø	�œ	Ð"Ø	�BœMÐ*ð€Eð €CØð >ð >‰	ˆˆcØ�S�S‘U”U”[Ô)Ñ)ˆØ-=°qÐ-=Ð-=Ð-=ˆÐ) 4Ð)Ð)Ñ*Ð*Ø€Jó    c                 ó„   ‡— t           j        t           j        t           j        t           j        g} h d£Šˆfd„| D ¦   «         S )N>   Úint128Úint256Úfloat80Úfloat96Úuint128Úuint256Úfloat128Úfloat256Ú
complex160Ú
complex192Ú
complex256Ú
complex512c                ó0   •— g | ]}|j         ‰v ¯|j         ‘ŒS © )Ú__name__)Ú.0ÚiÚextended_namess     €r4   ú
<listcomp>z0_get_extended_precision_list.<locals>.<listcomp>]   s'   ø€ ÐOÐOÐO˜1°!´*ÀÐ2NÐ2NˆAŒJÐ2NÐ2NÐ2Nr6   )r"   Ú	ulonglongr(   r,   Úclongdouble)Úextended_typesrI   s    @r4   Ú_get_extended_precision_listrN   M   sG   ø€ Ý”l¥B¤Kµ´ÅÄÐO€Nðð ð €Nð PÐOÐOÐO ÐOÑOÔOÐOr6   Ústrc                 óh   — t          j        d¦  «        j        } | dk    rdS | dk    rdS | dk    rdS dS )NÚprH   Úc_intÚlÚc_longÚqÚ
c_longlong)r"   r-   Úchar)rW   s    r4   Ú_get_c_intp_namerX   `   sA   € åŒ8�C‰=Œ=Ô€DØˆs‚{€{ØˆwØ	�ŠˆØˆxØ	�ŠˆØˆ|àˆxr6   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!   )r1   ÚsplitrY   Ú
named_type)r\   r2   Ú_Úapir1   Úname_news         r4   Ú_hookre   x   sJ   € à�K€CˆˆCØŒ8�>Š>˜#ÑÔ˜rÔ"€DÝÐ<°dÐ<Ð<Ô=€HØ�>Š>˜(Ñ#Ô#Ð#r6   Ú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`.rh   NzBFailed to identify a `ImportFrom` instance with the following id: )Ú	enumerateÚgetattrÚ
ValueError)rf   rh   rH   Úvalues       r4   Ú_indexro   �   sf   € å! (Ñ+Ô+ð 	ð 	‰HˆAˆuÝ�u˜d DÑ)Ô)¨RÒ/Ð/Ø���ð 0åð :Ø35ð:ð :ñ ;ô ;ð 	;r6   Ú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   )r/   TN)r   Úis_top_levelÚdefsrr   ro   )rp   rq   rr   Ú
import_objÚlstrH   s         r4   Ú_override_importsrz   ‰   s^   € õ   ¨°Ð9Ñ9Ô9ˆ
Ø"&ˆ
Ôð ”I˜tœ|Ð,ð 	 ð 	 ˆCÝ�s˜FÑ#Ô#ˆAØˆC�‰FˆFð	 ð 	 r6   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.ÚfullnamerO   r   úNone | _HookFuncc                ó&   — |t           v rt          S dS )z«Set the precision of platform-specific `numpy.number`
            subclasses.

            For example: `numpy.int_`, `numpy.longlong` and `numpy.longdouble`.
            N)rY   re   )Úselfr}   s     r4   Úget_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hook›   s   € ð �?Ð*Ð*Ý�Ø�4r6   rp   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 rE   rE   )rG   Úvs     r4   rJ   z4_NumpyPlugin.get_additional_deps.<locals>.<listcomp>µ   s   € ÐFÐFÐF¨˜a ˜VÐFÐFÐFr6   )rr   znumpy.ctypeslibÚctypesÚ_c_intp)r   r}   rz   rZ   r[   )r€   rp   r0   s      r4   Úget_additional_depsz _NumpyPlugin.get_additional_deps¥   s”   € õ ˜Tœ]¨BÐ/Ð0ˆCàŒ} Ò'Ð'Ý!ØÐ=ØFÐFÕ-EÐFÑFÔFðñ ô ð ð ð ”Ð"3Ò3Ð3Ý!Ø˜(Ý% yÐ1Ð2ðñ ô ð ð ˆJr6   N)r}   rO   r   r~   )rp   r   r   r‚   )rF   Ú
__module__Ú__qualname__Ú__doc__r�   r‰   rE   r6   r4   r|   r|   ˜   sB   € € € € € ØLÐLð	ð 	ð 	ð 	ð	ð 	ð 	ð 	ð 	ð 	r6   r|   Úversionútype[_NumpyPlugin]c                ó   — t           S ©zAn entry-point for mypy.)r|   ©r�   s    r4   Úpluginr’   ¾   s   € åÐr6   c                ó   — t           ‚r�   )r   r‘   s    r4   r’   r’   Ã   s   € åˆr6   )r   r   )r   r   )r   rO   )r\   r
   r   r   )rf   rg   rh   rO   r   ri   )rp   r   rq   rO   rr   rs   r   rt   )r�   rO   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   r5   rN   rX   rY   rZ   r[   re   ro   rz   r|   r’   rE   r6   r4   ú<module>r       s  ððð ð ðB #Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1à Ð Ð Ð ð
ØÐÐÐØÐÐÐÐÐØ6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ø:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ø"Ð"Ð"Ð"Ð"Ð"àÐ,Ð-¨tÐ3Ô4€IØ*.€GÐ.Ð.Ð.Ñ.Ð.øØð ð ð Ø€G€G€G€G€G€Gøøøøðøøøð €Ð Ð Ð Ñ ðð ð ð ð*Pð Pð Pð Pð&
ð 
ð 
ð 
ð -Ð,Ñ.Ô.€Ð .Ð .Ð .Ñ .ð #?Ð">Ñ"@Ô"@Ð Ð @Ð @Ð @Ñ @ð "Ð!Ñ#Ô#€Ð #Ð #Ð #Ñ #ð$ð $ð $ð $ð ð E�G�Oð;ð ;ð ;ð ;ð ð  ð  ð  ð$ð $ð $ð $ð $�vñ $ô $ð $ðLð ð ð ð ð ð
ð ð ð ð ð s   Ÿ4A ÁA%ÁA Á A%