From d36f69193c2c84181de50cc79af0e15e5dd8020f Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 16:52:22 +0900 Subject: [PATCH 1/4] allow the second element of `_PF` to be `None` --- stdlib/_ctypes.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index a04ded5709e8..056301338819 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -94,7 +94,7 @@ class _CArgObject: ... def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... _ECT: TypeAlias = Callable[[type[_CData] | None, CFuncPtr, tuple[_CData, ...]], _CData] -_PF: TypeAlias = tuple[int] | tuple[int, str] | tuple[int, str, Any] +_PF: TypeAlias = tuple[int] | tuple[int, str | None] | tuple[int, str | None, Any] class CFuncPtr(_PointerLike, _CData): restype: type[_CData] | Callable[[int], Any] | None From 45fd88bf722cda105cb810fbf46e434846a4a588 Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 16:52:22 +0900 Subject: [PATCH 2/4] allow `__paramflags` to be `None` --- stdlib/_ctypes.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 056301338819..5ff0577b4525 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -108,11 +108,11 @@ class CFuncPtr(_PointerLike, _CData): @overload 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 = ...) -> None: ... if sys.platform == "win32": @overload def __init__( - self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] = ..., __iid: _Pointer[c_int] = ... + self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] | None = ..., __iid: _Pointer[c_int] = ... ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... From 19671f9c808d3381201699c028f892606e5d8bcd Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 16:52:22 +0900 Subject: [PATCH 3/4] allow `__iid` to be `None` or `_CData` --- stdlib/_ctypes.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 5ff0577b4525..5a8f3df8be9d 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -112,7 +112,7 @@ class CFuncPtr(_PointerLike, _CData): if sys.platform == "win32": @overload def __init__( - self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] | None = ..., __iid: _Pointer[c_int] = ... + self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] | None = ..., __iid: _CData | None = ... ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... From ed9659bbd3b248c39cf23328e128335a338d779d Mon Sep 17 00:00:00 2001 From: junkmd Date: Sun, 7 May 2023 16:52:22 +0900 Subject: [PATCH 4/4] remove unused symbols --- stdlib/_ctypes.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 5a8f3df8be9d..e2f8fa745f27 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from ctypes import CDLL, c_int +from ctypes import CDLL from typing import Any, ClassVar, Generic, TypeVar, overload from typing_extensions import Self, TypeAlias