bgOUdZddlmZddlmZddlmZmZmZddl Z ddl Z ddl m Z ddlmZmZddlmZmZmZdd lmZeege fZdZd ed <n#e$r ZeZYdZ[ndZ[wwxYwgZd ed <d.dZd/dZd0dZeZ ded<eZ!ded<eZ"ded<d1dZ#esed2d Z$d3d'Z%Gd(d)eZ&d4d,Z'dSd4d-Z'dS)5aA 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 ` 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_CHECKINGCallableN)Type)PluginAnalyzeTypeContext)MypyFile ImportFrom Statement)PRI_MEDzNone | ModuleNotFoundErrorMYPY_EX list[str]__all__returndict[str, str]c hdtjfdtjfdtjfdtjfdtjfdtjfdtjfdtjfd tj fd tj fg }i}|D](\}}d |j j z}d |d |d|<)|S)N _NBitByte _NBitShort _NBitIntC _NBitIntP_NBitInt _NBitLongLong _NBitHalf _NBitSingle _NBitDouble_NBitLongDoubleznumpy._Bitnumpy._typing._nbit.) npbyteshortintcintpint_longlonghalfsingledouble longdoubledtypeitemsize)namesretnametypns k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/numpy/typing/mypy_plugin.py_get_precision_dictr58s bg rx bg bg RW "+& bg  "  " BM* E C>> cSSUU[))-=q-=-=-= )4 ) )** Jctjtjtjtjg}hdfd|DS)N> int128int256float80float96uint128uint256float128float256 complex160 complex192 complex256 complex512c0g|]}|jv |jS)__name__).0iextended_namess r4 z0_get_extended_precision_list..]s' O O O1!*2N2NAJ2N2N2Nr6)r" ulonglongr(r, clongdouble)extended_typesrIs @r4_get_extended_precision_listrNMsGlBKON   N P O O O O O OOr6strchtjdj}|dkrdS|dkrdS|dkrdSdS)NprHc_intlc_longq c_longlong)r"r-char)rWs r4_get_c_intp_namerX`sA 8C== D s{{w x |xr6r_PRECISION_DICT_EXTENDED_PRECISION_LIST_C_INTPctxr rc|\}}}|jdd}td|}||S)z;Replace a type-alias with a concrete ``NBitBase`` subclass..r!)r1splitrY named_type)r\r2_apir1name_news r4_hookrexsJKCC 8>>#  r "D>( # ##r6iterableIterable[Statement]idintct|D]\}}t|dd|kr|cStd|)z>Identify the first ``ImportFrom`` instance the specified `id`.rhNzBFailed to identify a `ImportFrom` instance with the following id: ) enumerategetattr ValueError)rfrhrHvalues r4_indexrosf!(++  HAuudD))R//0:35::;; ;r6filer moduleimportslist[tuple[str, None | str]]Nonect|d|}d|_|j|jfD]}t ||}|||<dS)zA mypy plugin for handling versus numpy-specific typing tasks.fullnamerOrNone | _HookFuncc&|tvrtSdS)zSet the precision of platform-specific `numpy.number` subclasses. For example: `numpy.int_`, `numpy.longlong` and `numpy.longdouble`. N)rYre)selfr}s r4get_type_analyze_hookz"_NumpyPlugin.get_type_analyze_hooks ?** 4r6rpr list[tuple[int, str, int]]ct|jdfg}|jdkr"t|ddtDn%|jdkrt|dtdfg|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_precisioncg|]}||fSrErE)rGvs r4rJz4_NumpyPlugin.get_additional_deps..sFFFaVFFFr6)rrznumpy.ctypeslibctypes_c_intp)rr}rzrZr[)rrpr0s r4get_additional_depsz _NumpyPlugin.get_additional_depssT]B/0C}''!=FF-EFFF"333!(%y12Jr6N)r}rOrr~)rpr rr)rF __module__ __qualname____doc__rrrEr6r4r|r|sBLL          r6r|versiontype[_NumpyPlugin]ctSzAn entry-point for mypy.)r|rs r4pluginrsr6ctr)rrs r4rrs r6)rr)rr)rrO)r\r rr)rfrgrhrOrri)rpr rqrOrrrsrrt)rrOrr)(r __future__rcollections.abcrtypingrrrrr" mypy.typesmypyr mypy.pluginr r mypy.nodesr r r mypy.buildr _HookFuncr__annotations__ModuleNotFoundErrorexrr5rNrXrYrZr[rerorzr|rrEr6r4rsB#"""""$$$$$$1111111111 66666666::::::::::"""""",-t34I*.G.....GGGGGG*PPPP&    -,......#?">"@"@@@@@"!######$$$$EGO;;;;     $$$$$v$$$L s4AA%A  A%