module documentation

Plugin to provide accurate types for some parts of the ctypes module.

Function array_constructor_callback Callback to provide an accurate signature for the ctypes.Array constructor.
Function array_getitem_callback Callback to provide an accurate return type for ctypes.Array.__getitem__.
Function array_iter_callback Callback to provide an accurate return type for ctypes.Array.__iter__.
Function array_raw_callback Callback to provide an accurate type for ctypes.Array.raw.
Function array_setitem_callback Callback to provide an accurate signature for ctypes.Array.__setitem__.
Function array_value_callback Callback to provide an accurate type for ctypes.Array.value.
Function _autoconvertible_to_cdata Get a type that is compatible with all types that can be implicitly converted to the given CData type.
Function _autounboxed_cdata Get the auto-unboxed version of a CData type, if applicable.
Function _find_simplecdata_base_arg Try to find a parametrized _SimpleCData in tp's bases and return its single type argument.
Function _get_array_element_type Get the element type of the Array type tp, or None if not specified.
def array_constructor_callback(ctx: mypy.plugin.FunctionContext) -> Type: (source)

Callback to provide an accurate signature for the ctypes.Array constructor.

def array_getitem_callback(ctx: mypy.plugin.MethodContext) -> Type: (source)

Callback to provide an accurate return type for ctypes.Array.__getitem__.

def array_iter_callback(ctx: mypy.plugin.MethodContext) -> Type: (source)

Callback to provide an accurate return type for ctypes.Array.__iter__.

def array_raw_callback(ctx: mypy.plugin.AttributeContext) -> Type: (source)

Callback to provide an accurate type for ctypes.Array.raw.

def array_setitem_callback(ctx: mypy.plugin.MethodSigContext) -> CallableType: (source)

Callback to provide an accurate signature for ctypes.Array.__setitem__.

def array_value_callback(ctx: mypy.plugin.AttributeContext) -> Type: (source)

Callback to provide an accurate type for ctypes.Array.value.

def _autoconvertible_to_cdata(tp: Type, api: mypy.plugin.CheckerPluginInterface) -> Type: (source)

Get a type that is compatible with all types that can be implicitly converted to the given CData type. Examples: * c_int -> Union[c_int, int] * c_char_p -> Union[c_char_p, bytes, int, NoneType] * MyStructure -> MyStructure

def _autounboxed_cdata(tp: Type) -> ProperType: (source)

Get the auto-unboxed version of a CData type, if applicable. For *direct* _SimpleCData subclasses, the only type argument of _SimpleCData in the bases list is returned. For all other CData types, including indirect _SimpleCData subclasses, tp is returned as-is.

def _find_simplecdata_base_arg(tp: Instance, api: mypy.plugin.CheckerPluginInterface) -> ProperType|None: (source)

Try to find a parametrized _SimpleCData in tp's bases and return its single type argument. None is returned if _SimpleCData appears nowhere in tp's (direct or indirect) bases.

def _get_array_element_type(tp: Type) -> ProperType|None: (source)

Get the element type of the Array type tp, or None if not specified.