8000 Add `stdlib/_ctypes` · Issue #8571 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content
Add stdlib/_ctypes #8571
@junkmd

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.

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.

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

      0