Skip to content

Commit

Permalink
update constructor args of the CFuncPtr to expand acceptable types (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
junkmd authored May 7, 2023
1 parent 38a11b2 commit 9457de3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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: ...
Expand Down

0 comments on commit 9457de3

Please sign in to comment.