mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-09 03:01:25 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,23 +1,35 @@
|
||||
# Stubs for ctypes
|
||||
|
||||
import sys
|
||||
from array import array
|
||||
from typing import (
|
||||
Any, Callable, ClassVar, Iterator, Iterable, List, Mapping, Optional, Sequence, Sized, Text,
|
||||
Tuple, Type, Generic, TypeVar, overload,
|
||||
Any,
|
||||
Callable,
|
||||
ClassVar,
|
||||
Generic,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Sized,
|
||||
Text,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union as _UnionT,
|
||||
overload,
|
||||
)
|
||||
from typing import Union as _UnionT
|
||||
import sys
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_DLLT = TypeVar('_DLLT', bound=CDLL)
|
||||
_CT = TypeVar('_CT', bound=_CData)
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_DLLT = TypeVar("_DLLT", bound=CDLL)
|
||||
_CT = TypeVar("_CT", bound=_CData)
|
||||
|
||||
RTLD_GLOBAL: int = ...
|
||||
RTLD_LOCAL: int = ...
|
||||
DEFAULT_MODE: int = ...
|
||||
|
||||
|
||||
class CDLL(object):
|
||||
_func_flags_: ClassVar[int] = ...
|
||||
_func_restype_: ClassVar[_CData] = ...
|
||||
@@ -35,9 +47,11 @@ class CDLL(object):
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str) -> _FuncPointer: ...
|
||||
def __getitem__(self, name: str) -> _FuncPointer: ...
|
||||
if sys.platform == 'win32':
|
||||
|
||||
if sys.platform == "win32":
|
||||
class OleDLL(CDLL): ...
|
||||
class WinDLL(CDLL): ...
|
||||
|
||||
class PyDLL(CDLL): ...
|
||||
|
||||
class LibraryLoader(Generic[_DLLT]):
|
||||
@@ -47,7 +61,7 @@ class LibraryLoader(Generic[_DLLT]):
|
||||
def LoadLibrary(self, name: str) -> _DLLT: ...
|
||||
|
||||
cdll: LibraryLoader[CDLL] = ...
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
windll: LibraryLoader[WinDLL] = ...
|
||||
oledll: LibraryLoader[OleDLL] = ...
|
||||
pydll: LibraryLoader[PyDLL] = ...
|
||||
@@ -66,6 +80,7 @@ class _CDataMeta(type):
|
||||
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
|
||||
def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
|
||||
def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
|
||||
|
||||
class _CData(metaclass=_CDataMeta):
|
||||
_b_base: int = ...
|
||||
_b_needsfree_: bool = ...
|
||||
@@ -83,15 +98,9 @@ class _CData(metaclass=_CDataMeta):
|
||||
|
||||
class _PointerLike(_CData): ...
|
||||
|
||||
_ECT = Callable[[Optional[Type[_CData]],
|
||||
_FuncPointer,
|
||||
Tuple[_CData, ...]],
|
||||
_CData]
|
||||
_PF = _UnionT[
|
||||
Tuple[int],
|
||||
Tuple[int, str],
|
||||
Tuple[int, str, Any]
|
||||
]
|
||||
_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData]
|
||||
_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]]
|
||||
|
||||
class _FuncPointer(_PointerLike, _CData):
|
||||
restype: _UnionT[Type[_CData], Callable[[int], None], None] = ...
|
||||
argtypes: Sequence[Type[_CData]] = ...
|
||||
@@ -101,28 +110,23 @@ class _FuncPointer(_PointerLike, _CData):
|
||||
@overload
|
||||
def __init__(self, callable: Callable[..., Any]) -> None: ...
|
||||
@overload
|
||||
def __init__(self, func_spec: Tuple[_UnionT[str, int], CDLL],
|
||||
paramflags: Tuple[_PF, ...] = ...) -> None: ...
|
||||
def __init__(self, func_spec: Tuple[_UnionT[str, int], CDLL], paramflags: Tuple[_PF, ...] = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, vtlb_index: int, name: str,
|
||||
paramflags: Tuple[_PF, ...] = ...,
|
||||
iid: pointer[c_int] = ...) -> None: ...
|
||||
def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
class ArgumentError(Exception): ...
|
||||
|
||||
def CFUNCTYPE(
|
||||
restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> Type[_FuncPointer]: ...
|
||||
|
||||
def CFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData],
|
||||
use_errno: bool = ...,
|
||||
use_last_error: bool = ...) -> Type[_FuncPointer]: ...
|
||||
if sys.platform == 'win32':
|
||||
def WINFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData],
|
||||
use_errno: bool = ...,
|
||||
use_last_error: bool = ...) -> Type[_FuncPointer]: ...
|
||||
def PYFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData]) -> Type[_FuncPointer]: ...
|
||||
if sys.platform == "win32":
|
||||
def WINFUNCTYPE(
|
||||
restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> Type[_FuncPointer]: ...
|
||||
|
||||
def PYFUNCTYPE(restype: Optional[Type[_CData]], *argtypes: Type[_CData]) -> Type[_FuncPointer]: ...
|
||||
|
||||
class _CArgObject: ...
|
||||
|
||||
@@ -138,21 +142,27 @@ _CVoidConstPLike = _UnionT[_CVoidPLike, bytes]
|
||||
def addressof(obj: _CData) -> int: ...
|
||||
def alignment(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
|
||||
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||
_PT = TypeVar('_PT', bound=_PointerLike)
|
||||
|
||||
_PT = TypeVar("_PT", bound=_PointerLike)
|
||||
|
||||
def cast(obj: _UnionT[_CData, _CArgObject], type: Type[_PT]) -> _PT: ...
|
||||
def create_string_buffer(init_or_size: _UnionT[int, bytes],
|
||||
size: Optional[int] = ...) -> Array[c_char]: ...
|
||||
def create_string_buffer(init_or_size: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ...
|
||||
|
||||
c_buffer = create_string_buffer
|
||||
def create_unicode_buffer(init_or_size: _UnionT[int, Text],
|
||||
size: Optional[int] = ...) -> Array[c_wchar]: ...
|
||||
if sys.platform == 'win32':
|
||||
|
||||
def create_unicode_buffer(init_or_size: _UnionT[int, Text], size: Optional[int] = ...) -> Array[c_wchar]: ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
def DllCanUnloadNow() -> int: ...
|
||||
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
|
||||
def FormatError(code: int) -> str: ...
|
||||
def GetLastError() -> int: ...
|
||||
|
||||
def get_errno() -> int: ...
|
||||
if sys.platform == 'win32':
|
||||
|
||||
if sys.platform == "win32":
|
||||
def get_last_error() -> int: ...
|
||||
|
||||
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ...
|
||||
def memset(dst: _CVoidPLike, c: int, count: int) -> None: ...
|
||||
def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ...
|
||||
@@ -174,16 +184,21 @@ class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
def __setitem__(self, s: slice, o: Iterable[_CT]) -> None: ...
|
||||
|
||||
def resize(obj: _CData, size: int) -> None: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ...
|
||||
|
||||
def set_errno(value: int) -> int: ...
|
||||
if sys.platform == 'win32':
|
||||
|
||||
if sys.platform == "win32":
|
||||
def set_last_error(value: int) -> int: ...
|
||||
|
||||
def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
|
||||
def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ...
|
||||
if sys.platform == 'win32':
|
||||
def WinError(code: Optional[int] = ...,
|
||||
descr: Optional[str] = ...) -> OSError: ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
def WinError(code: Optional[int] = ..., descr: Optional[str] = ...) -> OSError: ...
|
||||
|
||||
def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ...
|
||||
|
||||
class _SimpleCData(Generic[_T], _CData):
|
||||
@@ -194,50 +209,42 @@ class c_byte(_SimpleCData[int]): ...
|
||||
|
||||
class c_char(_SimpleCData[bytes]):
|
||||
def __init__(self, value: _UnionT[int, bytes] = ...) -> None: ...
|
||||
|
||||
class c_char_p(_PointerLike, _SimpleCData[Optional[bytes]]):
|
||||
def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ...
|
||||
|
||||
class c_double(_SimpleCData[float]): ...
|
||||
class c_longdouble(_SimpleCData[float]): ...
|
||||
class c_float(_SimpleCData[float]): ...
|
||||
|
||||
class c_int(_SimpleCData[int]): ...
|
||||
class c_int8(_SimpleCData[int]): ...
|
||||
class c_int16(_SimpleCData[int]): ...
|
||||
class c_int32(_SimpleCData[int]): ...
|
||||
class c_int64(_SimpleCData[int]): ...
|
||||
|
||||
class c_long(_SimpleCData[int]): ...
|
||||
class c_longlong(_SimpleCData[int]): ...
|
||||
|
||||
class c_short(_SimpleCData[int]): ...
|
||||
|
||||
class c_size_t(_SimpleCData[int]): ...
|
||||
class c_ssize_t(_SimpleCData[int]): ...
|
||||
|
||||
class c_ubyte(_SimpleCData[int]): ...
|
||||
|
||||
class c_uint(_SimpleCData[int]): ...
|
||||
class c_uint8(_SimpleCData[int]): ...
|
||||
class c_uint16(_SimpleCData[int]): ...
|
||||
class c_uint32(_SimpleCData[int]): ...
|
||||
class c_uint64(_SimpleCData[int]): ...
|
||||
|
||||
class c_ulong(_SimpleCData[int]): ...
|
||||
class c_ulonglong(_SimpleCData[int]): ...
|
||||
|
||||
class c_ushort(_SimpleCData[int]): ...
|
||||
|
||||
class c_void_p(_PointerLike, _SimpleCData[Optional[int]]): ...
|
||||
|
||||
class c_wchar(_SimpleCData[Text]): ...
|
||||
|
||||
class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]):
|
||||
def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ...
|
||||
|
||||
class c_bool(_SimpleCData[bool]):
|
||||
def __init__(self, value: bool = ...) -> None: ...
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
|
||||
|
||||
class py_object(_SimpleCData[_T]): ...
|
||||
@@ -245,11 +252,13 @@ class py_object(_SimpleCData[_T]): ...
|
||||
class _CField:
|
||||
offset: int = ...
|
||||
size: int = ...
|
||||
|
||||
class _StructUnionMeta(_CDataMeta):
|
||||
_fields_: Sequence[_UnionT[Tuple[str, Type[_CData]], Tuple[str, Type[_CData], int]]] = ...
|
||||
_pack_: int = ...
|
||||
_anonymous_: Sequence[str] = ...
|
||||
def __getattr__(self, name: str) -> _CField: ...
|
||||
|
||||
class _StructUnionBase(_CData, metaclass=_StructUnionMeta):
|
||||
def __init__(self, *args: Any, **kw: Any) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Stubs for ctypes.util
|
||||
|
||||
from typing import Optional
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
def find_library(name: str) -> Optional[str]: ...
|
||||
if sys.platform == 'win32':
|
||||
|
||||
if sys.platform == "win32":
|
||||
def find_msvcrt() -> Optional[str]: ...
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
from ctypes import (
|
||||
_SimpleCData, Array, Structure, c_byte, c_char, c_char_p, c_double, c_float, c_int, c_long,
|
||||
c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort, c_void_p, c_wchar, c_wchar_p,
|
||||
Array,
|
||||
Structure,
|
||||
_SimpleCData,
|
||||
c_byte,
|
||||
c_char,
|
||||
c_char_p,
|
||||
c_double,
|
||||
c_float,
|
||||
c_int,
|
||||
c_long,
|
||||
c_longlong,
|
||||
c_short,
|
||||
c_uint,
|
||||
c_ulong,
|
||||
c_ulonglong,
|
||||
c_ushort,
|
||||
c_void_p,
|
||||
c_wchar,
|
||||
c_wchar_p,
|
||||
pointer,
|
||||
)
|
||||
|
||||
@@ -15,7 +32,9 @@ DOUBLE = c_double
|
||||
FLOAT = c_float
|
||||
BOOLEAN = BYTE
|
||||
BOOL = c_long
|
||||
|
||||
class VARIANT_BOOL(_SimpleCData[bool]): ...
|
||||
|
||||
ULONG = c_ulong
|
||||
LONG = c_long
|
||||
USHORT = c_ushort
|
||||
@@ -86,6 +105,7 @@ class RECT(Structure):
|
||||
top: LONG
|
||||
right: LONG
|
||||
bottom: LONG
|
||||
|
||||
RECTL = RECT
|
||||
_RECTL = RECT
|
||||
tagRECT = RECT
|
||||
@@ -95,6 +115,7 @@ class _SMALL_RECT(Structure):
|
||||
Top: SHORT
|
||||
Right: SHORT
|
||||
Bottom: SHORT
|
||||
|
||||
SMALL_RECT = _SMALL_RECT
|
||||
|
||||
class _COORD(Structure):
|
||||
@@ -104,6 +125,7 @@ class _COORD(Structure):
|
||||
class POINT(Structure):
|
||||
x: LONG
|
||||
y: LONG
|
||||
|
||||
POINTL = POINT
|
||||
_POINTL = POINT
|
||||
tagPOINT = POINT
|
||||
@@ -111,6 +133,7 @@ tagPOINT = POINT
|
||||
class SIZE(Structure):
|
||||
cx: LONG
|
||||
cy: LONG
|
||||
|
||||
SIZEL = SIZE
|
||||
tagSIZE = SIZE
|
||||
|
||||
@@ -119,6 +142,7 @@ def RGB(red: int, green: int, blue: int) -> int: ...
|
||||
class FILETIME(Structure):
|
||||
dwLowDateTime: DWORD
|
||||
dwHighDateTime: DWORD
|
||||
|
||||
_FILETIME = FILETIME
|
||||
|
||||
class MSG(Structure):
|
||||
@@ -128,6 +152,7 @@ class MSG(Structure):
|
||||
lParam: LPARAM
|
||||
time: DWORD
|
||||
pt: POINT
|
||||
|
||||
tagMSG = MSG
|
||||
MAX_PATH: int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user