Use PEP 570 syntax in third party stubs (#11554)

This commit is contained in:
Shantanu
2024-03-10 06:11:43 -07:00
committed by GitHub
parent f94bbfbcc4
commit 88fa182253
97 changed files with 625 additions and 632 deletions
+47 -45
View File
@@ -137,10 +137,10 @@ class FFI:
_includes: tuple[FFI, ...] = ...,
) -> None: ...
@overload
def addressof(self, __cdata: CData, *field_or_index: str | int) -> CData: ...
def addressof(self, cdata: CData, /, *field_or_index: str | int) -> CData: ...
@overload
def addressof(self, __library: Lib, __name: str) -> CData: ...
def alignof(self, __cdecl: str | CType | CData) -> int: ...
def addressof(self, library: Lib, name: str, /) -> CData: ...
def alignof(self, cdecl: str | CType | CData, /) -> int: ...
@overload
def callback(
self,
@@ -161,11 +161,11 @@ class FFI:
def def_extern(
self, name: str = ..., error: Any = ..., onerror: Callable[[Exception, Any, types.TracebackType], Any] = ...
) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def dlclose(self, __lib: Lib) -> None: ...
def dlclose(self, lib: Lib, /) -> None: ...
if sys.platform == "win32":
def dlopen(self, __libpath: str | CData, __flags: int = ...) -> Lib: ...
def dlopen(self, libpath: str | CData, flags: int = ..., /) -> Lib: ...
else:
def dlopen(self, __libpath: str | CData | None = ..., __flags: int = ...) -> Lib: ...
def dlopen(self, libpath: str | CData | None = ..., flags: int = ..., /) -> Lib: ...
@overload
def from_buffer(self, cdecl: ReadableBuffer, require_writable: Literal[False] = ...) -> CData: ...
@@ -175,7 +175,7 @@ class FFI:
def from_buffer(self, cdecl: str | CType, python_buffer: ReadableBuffer, require_writable: Literal[False] = ...) -> CData: ...
@overload
def from_buffer(self, cdecl: str | CType, python_buffer: WriteableBuffer, require_writable: Literal[True]) -> CData: ...
def from_handle(self, __x: CData) -> Any: ...
def from_handle(self, x: CData, /) -> Any: ...
@overload
def gc(self, cdata: CData, destructor: Callable[[CData], Any], size: int = ...) -> CData: ...
@overload
@@ -199,68 +199,70 @@ class FFI:
def new_allocator(
self, alloc: Callable[[int], CData], free: Callable[[CData], Any], should_clear_after_alloc: bool = ...
) -> _Allocator: ...
def new_handle(self, __x: Any) -> CData: ...
def offsetof(self, __cdecl: str | CType, __field_or_index: str | int, *__fields_or_indexes: str | int) -> int: ...
def release(self, __cdata: CData) -> None: ...
def sizeof(self, __cdecl: str | CType | CData) -> int: ...
def new_handle(self, x: Any, /) -> CData: ...
def offsetof(self, cdecl: str | CType, field_or_index: str | int, /, *__fields_or_indexes: str | int) -> int: ...
def release(self, cdata: CData, /) -> None: ...
def sizeof(self, cdecl: str | CType | CData, /) -> int: ...
def string(self, cdata: CData, maxlen: int = -1) -> bytes | str: ...
def typeof(self, cdecl: str | CData) -> CType: ...
def unpack(self, cdata: CData, length: int) -> bytes | str | list[Any]: ...
def alignof(__cdecl: CType) -> int: ...
def alignof(cdecl: CType, /) -> int: ...
def callback(
__cdecl: CType,
__python_callable: Callable[..., _T],
__error: Any = ...,
__onerror: Callable[[Exception, Any, Any], None] | None = ...,
cdecl: CType,
python_callable: Callable[..., _T],
error: Any = ...,
onerror: Callable[[Exception, Any, Any], None] | None = ...,
/,
) -> Callable[..., _T]: ...
def cast(__cdecl: CType, __value: _CDataBase) -> _CDataBase: ...
def cast(cdecl: CType, value: _CDataBase, /) -> _CDataBase: ...
def complete_struct_or_union(
__cdecl: CType,
__fields: list[tuple[str, CType, int, int]],
__ignored: Any,
__total_size: int,
__total_alignment: int,
__sflags: int,
__pack: int,
cdecl: CType,
fields: list[tuple[str, CType, int, int]],
ignored: Any,
total_size: int,
total_alignment: int,
sflags: int,
pack: int,
/,
) -> None: ...
@overload
def from_buffer(__cdecl: CType, __python_buffer: ReadableBuffer, require_writable: Literal[False] = ...) -> _CDataBase: ...
def from_buffer(cdecl: CType, python_buffer: ReadableBuffer, /, require_writable: Literal[False] = ...) -> _CDataBase: ...
@overload
def from_buffer(__cdecl: CType, __python_buffer: WriteableBuffer, require_writable: Literal[True]) -> _CDataBase: ...
def from_handle(__x: _CDataBase) -> Any: ...
def from_buffer(cdecl: CType, python_buffer: WriteableBuffer, /, require_writable: Literal[True]) -> _CDataBase: ...
def from_handle(x: _CDataBase, /) -> Any: ...
@overload
def gcp(cdata: _CDataBase, destructor: Callable[[_CDataBase], Any], size: int = ...) -> _CDataBase: ...
@overload
def gcp(cdata: _CDataBase, destructor: None, size: int = ...) -> None: ...
def get_errno() -> int: ...
def getcname(__cdecl: CType, __replace_with: str) -> str: ...
def getcname(cdecl: CType, replace_with: str, /) -> str: ...
if sys.platform == "win32":
def getwinerror(code: int = ...) -> tuple[int, str]: ...
if sys.platform == "win32":
def load_library(__libpath: str | _CDataBase, __flags: int = ...) -> CLibrary: ...
def load_library(libpath: str | _CDataBase, flags: int = ..., /) -> CLibrary: ...
else:
def load_library(__libpath: str | _CDataBase | None = ..., __flags: int = ...) -> CLibrary: ...
def load_library(libpath: str | _CDataBase | None = ..., flags: int = ..., /) -> CLibrary: ...
def memmove(dest: _CDataBase | WriteableBuffer, src: _CDataBase | ReadableBuffer, n: int) -> None: ...
def new_array_type(__cdecl: CType, __length: int | None) -> CType: ...
def new_enum_type(__name: str, __enumerators: tuple[str, ...], __enumvalues: tuple[Any, ...], __basetype: CType) -> CType: ...
def new_function_type(__args: tuple[CType, ...], __result: CType, __ellipsis: int, __abi: int) -> CType: ...
def new_pointer_type(__cdecl: CType) -> CType: ...
def new_primitive_type(__name: str) -> CType: ...
def new_struct_type(__name: str) -> CType: ...
def new_union_type(__name: str) -> CType: ...
def new_array_type(cdecl: CType, length: int | None, /) -> CType: ...
def new_enum_type(name: str, enumerators: tuple[str, ...], enumvalues: tuple[Any, ...], basetype: CType, /) -> CType: ...
def new_function_type(args: tuple[CType, ...], result: CType, ellipsis: int, abi: int, /) -> CType: ...
def new_pointer_type(cdecl: CType, /) -> CType: ...
def new_primitive_type(name: str, /) -> CType: ...
def new_struct_type(name: str, /) -> CType: ...
def new_union_type(name: str, /) -> CType: ...
def new_void_type() -> CType: ...
def newp(__cdecl: CType, __init: Any = ...) -> _CDataBase: ...
def newp_handle(__cdecl: CType, __x: Any) -> _CDataBase: ...
def rawaddressof(__cdecl: CType, __cdata: _CDataBase, __offset: int) -> _CDataBase: ...
def release(__cdata: _CDataBase) -> None: ...
def set_errno(__errno: int) -> None: ...
def sizeof(__cdecl: CType | _CDataBase) -> int: ...
def newp(cdecl: CType, init: Any = ..., /) -> _CDataBase: ...
def newp_handle(cdecl: CType, x: Any, /) -> _CDataBase: ...
def rawaddressof(cdecl: CType, cdata: _CDataBase, offset: int, /) -> _CDataBase: ...
def release(cdata: _CDataBase, /) -> None: ...
def set_errno(errno: int, /) -> None: ...
def sizeof(cdecl: CType | _CDataBase, /) -> int: ...
def string(cdata: _CDataBase, maxlen: int) -> bytes | str: ...
def typeof(__cdata: _CDataBase) -> CType: ...
def typeoffsetof(__cdecl: CType, __fieldname: str | int, __following: bool = ...) -> tuple[CType, int]: ...
def typeof(cdata: _CDataBase, /) -> CType: ...
def typeoffsetof(cdecl: CType, fieldname: str | int, following: bool = ..., /) -> tuple[CType, int]: ...
def unpack(cdata: _CDataBase, length: int) -> bytes | str | list[Any]: ...