update constructor args of the CFuncPtr to expand acceptable types (#10155)

* allow the second element of `_PF` to be `None`

* allow `__paramflags` to be `None`

* allow `__iid` to be `None` or `_CData`

* remove unused symbols
This commit is contained in:
Jun Komoda
2023-05-07 23:32:58 +09:00
committed by GitHub
parent 38a11b2f06
commit 9457de310a

View File

@@ -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
@@ -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
@@ -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: _CData | None = ...
) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...