Move some pointer-related definitions from ctypes/__init__.pyi to _ctypes.pyi (#10133)

This commit is contained in:
Jun Komoda
2023-05-03 18:04:13 +09:00
committed by GitHub
parent 06878a98be
commit 01b09d4371
3 changed files with 25 additions and 23 deletions

View File

@@ -2,7 +2,7 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from abc import abstractmethod
from collections.abc import Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, _CArgObject, _PointerLike
from ctypes import CDLL, _CArgObject
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self, TypeAlias
@@ -70,6 +70,25 @@ class _SimpleCData(Generic[_T], _CData):
# but we can't use overloads without creating many, many mypy false-positive errors
def __init__(self, value: _T = ...) -> None: ... # pyright: ignore[reportInvalidTypeVarUse]
class _CanCastTo(_CData): ...
class _PointerLike(_CanCastTo): ...
class _Pointer(Generic[_CT], _PointerLike, _CData):
_type_: type[_CT]
contents: _CT
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, arg: _CT) -> None: ...
@overload
def __getitem__(self, __key: int) -> Any: ...
@overload
def __getitem__(self, __key: slice) -> list[Any]: ...
def __setitem__(self, __key: int, __value: Any) -> None: ...
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
def pointer(__arg: _CT) -> _Pointer[_CT]: ...
class _CField:
offset: int
size: int