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
.
New in version 1.22.
To enable the plugin, one must add it to their mypy configuration file:
[mypy] plugins = numpy.typing.mypy_plugin
Constant | MYPY_EX |
Undocumented |
Class | _NumpyPlugin |
A mypy plugin for handling versus numpy-specific typing tasks. |
Function | _get_c_intp_name |
Undocumented |
Function | _get_extended_precision_list |
Undocumented |
Function | _get_precision_dict |
Undocumented |
Function | _hook |
Replace a type-alias with a concrete NBitBase subclass. |
Function | _index |
Identify the first ImportFrom instance the specified id . |
Function | _override_imports |
Override the first module -based import with new imports . |
Function | plugin |
An entry-point for mypy. |
Constant | _C_INTP |
Undocumented |
Constant | _EXTENDED_PRECISION_LIST |
Undocumented |
Constant | _PRECISION_DICT |
Undocumented |
Variable | _HookFunc |
Undocumented |
Parameters | |
ctx:AnalyzeTypeContext | Undocumented |
Returns | |
Type | Undocumented |
id
.Parameters | |
iterable:Iterable[ | Undocumented |
id:str | Undocumented |
Returns | |
int | Undocumented |
module
-based import with new imports
.Parameters | |
file:MypyFile | Undocumented |
module:str | Undocumented |
imports:list[ | Undocumented |
Parameters | |
version:str | Undocumented |
Returns | |
type[ | Undocumented |