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.
from ctypes import _CArgObject, _PointerLike
# are they correct?
_COMError_Details = tuple[str | None, str | None, str | None, int | None, int | None] # Description, Source, HelpFile, HelpContext, scode
class COMError(Exception):
"""Raised when a COM method call failed."""
hresult: int
text: str
details: _COMError_Details
def __init__(self, hresult: _COMError_HResult, text: str, details: _COMError_Details) -> None: ...
def CopyComPointer(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.
My projects use some COM-ffi packages.
I use
_ctypes.COMErroror_ctypes.CopyComPointertoo, but they are not defined in the type stub, somypytype checker raisesCannot find implementation or library stub for module named "_ctypes"error.I would like to add type stubs like this.
But other APIs are not clear to me.
if sys.platform == "win32":needed.Any opinions would be appreciated.