From 9d7beb0865c4774268c2ae3fc01d2b52a7cdb3a9 Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 11:33:02 +0900 Subject: [PATCH 1/4] add a conditional branch for Windows only --- stdlib/_ctypes.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 3e3c8d29ac7d..3a344a624cf6 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -107,8 +107,10 @@ class CFuncPtr(_PointerLike, _CData): def __init__(self, callable: Callable[..., Any]) -> None: ... @overload def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... - @overload - def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... + if sys.platform == "win32": + @overload + def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class _CField: From e86ea2e52e4b1feda4401f503a23845407c83044 Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 11:33:53 +0900 Subject: [PATCH 2/4] fix argname spelling `vtlb_index` -> `vtbl_index` --- stdlib/_ctypes.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 3a344a624cf6..0d6cf64363bf 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -109,7 +109,7 @@ class CFuncPtr(_PointerLike, _CData): def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... if sys.platform == "win32": @overload - def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... + def __init__(self, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... From e36b5175d9ff60fdc59c53bdd7d2c8d07c983f42 Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 11:35:20 +0900 Subject: [PATCH 3/4] add an overload for the case where no arguments are passed to the constructor --- stdlib/_ctypes.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 0d6cf64363bf..6c3c01962c47 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -102,6 +102,8 @@ class CFuncPtr(_PointerLike, _CData): errcheck: _ECT _flags_: ClassVar[int] # Abstract attribute that must be defined on subclasses @overload + def __init__(self) -> None: ... + @overload def __init__(self, address: int) -> None: ... @overload def __init__(self, callable: Callable[..., Any]) -> None: ... From 35b1273146582d952974158568f46f74d189da1c Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 11:40:59 +0900 Subject: [PATCH 4/4] mark all of the arguments as positional-only --- stdlib/_ctypes.pyi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 6c3c01962c47..a04ded5709e8 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -104,14 +104,16 @@ class CFuncPtr(_PointerLike, _CData): @overload def __init__(self) -> None: ... @overload - def __init__(self, address: int) -> None: ... + def __init__(self, __address: int) -> None: ... @overload - def __init__(self, callable: Callable[..., Any]) -> None: ... + def __init__(self, __callable: Callable[..., Any]) -> None: ... @overload - def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... + def __init__(self, __func_spec: tuple[str | int, CDLL], __paramflags: tuple[_PF, ...] = ...) -> None: ... if sys.platform == "win32": @overload - def __init__(self, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... + def __init__( + self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] = ..., __iid: _Pointer[c_int] = ... + ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ...