mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 19:01:15 +08:00
Move some pointer-related definitions from ctypes/__init__.pyi to _ctypes.pyi (#10133)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user