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 toctypes.c_int64
.New in version 1.22.
Examples
To enable the plugin, one must add it to their mypy configuration file:
[mypy] plugins = numpy.typing.mypy_plugin
Function | plugin |
An entry-point for mypy. |
Constant | MYPY |
Undocumented |
Class | _ |
A mypy plugin for handling versus numpy-specific typing tasks. |
Function | _get |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
Undocumented |
Function | _hook |
Replace a type-alias with a concrete NBitBase subclass. |
Function | _index |
Identify the first ImportFrom instance the specified id . |
Function | _override |
Override the first module -based import with new imports . |
Constant | _C |
Undocumented |
Constant | _EXTENDED |
Undocumented |
Constant | _PRECISION |
Undocumented |
Type Alias | _ |
Undocumented |