Skip to content

Add stdlib/_ctypes #8571

Description

@junkmd

My projects use some COM-ffi packages.

I use _ctypes.COMError or _ctypes.CopyComPointer too, but they are not defined in the type stub, so mypy type checker raises Cannot find implementation or library stub for module named "_ctypes" error.

I would like to add type stubs like this.

fromctypesimport_CArgObject, _PointerLike# are they correct?_COMError_Details=tuple[str|None, str|None, str|None, int|None, int|None] # Description, Source, HelpFile, HelpContext, scodeclassCOMError(Exception):
"""Raised when a COM method call failed."""hresult: inttext: strdetails: _COMError_Detailsdef__init__(self, hresult: _COMError_HResult, text: str, details: _COMError_Details) ->None: ...
defCopyComPointer(src: _PointerLike, dst: _PointerLike|_CArgObject) ->int: ... # `dst` sometimes maybe return value of `ctypes.byref`."""CopyComPointer(src, dst) -> HRESULT value"""

But other APIs are not clear to me.

  • and where the if sys.platform == "win32": needed.

Any opinions would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions