mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-23 19:41:51 +08:00
Use lowercase type everywhere (#6853)
This commit is contained in:
@@ -11,7 +11,6 @@ from typing import (
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union as _UnionT,
|
||||
overload,
|
||||
@@ -33,7 +32,7 @@ class CDLL:
|
||||
_func_restype_: ClassVar[_CData]
|
||||
_name: str
|
||||
_handle: int
|
||||
_FuncPtr: Type[_FuncPointer]
|
||||
_FuncPtr: type[_FuncPointer]
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -58,7 +57,7 @@ if sys.platform == "win32":
|
||||
class PyDLL(CDLL): ...
|
||||
|
||||
class LibraryLoader(Generic[_DLLT]):
|
||||
def __init__(self, dlltype: Type[_DLLT]) -> None: ...
|
||||
def __init__(self, dlltype: type[_DLLT]) -> None: ...
|
||||
def __getattr__(self, name: str) -> _DLLT: ...
|
||||
def __getitem__(self, name: str) -> _DLLT: ...
|
||||
def LoadLibrary(self, name: str) -> _DLLT: ...
|
||||
@@ -76,33 +75,33 @@ class _CDataMeta(type):
|
||||
# By default mypy complains about the following two methods, because strictly speaking cls
|
||||
# might not be a Type[_CT]. However this can never actually happen, because the only class that
|
||||
# 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[misc]
|
||||
def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore[misc]
|
||||
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
|
||||
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
|
||||
|
||||
class _CData(metaclass=_CDataMeta):
|
||||
_b_base: int
|
||||
_b_needsfree_: bool
|
||||
_objects: Mapping[Any, int] | None
|
||||
@classmethod
|
||||
def from_buffer(cls: Type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ...
|
||||
def from_buffer(cls: type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ...
|
||||
@classmethod
|
||||
def from_buffer_copy(cls: Type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ...
|
||||
def from_buffer_copy(cls: type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ...
|
||||
@classmethod
|
||||
def from_address(cls: Type[_CT], address: int) -> _CT: ...
|
||||
def from_address(cls: type[_CT], address: int) -> _CT: ...
|
||||
@classmethod
|
||||
def from_param(cls: Type[_CT], obj: Any) -> _CT | _CArgObject: ...
|
||||
def from_param(cls: type[_CT], obj: Any) -> _CT | _CArgObject: ...
|
||||
@classmethod
|
||||
def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ...
|
||||
def in_dll(cls: type[_CT], library: CDLL, name: str) -> _CT: ...
|
||||
|
||||
class _CanCastTo(_CData): ...
|
||||
class _PointerLike(_CanCastTo): ...
|
||||
|
||||
_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, tuple[_CData, ...]], _CData]
|
||||
_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: Type[_CData] | Callable[[int], Any] | None
|
||||
argtypes: Sequence[Type[_CData]]
|
||||
restype: type[_CData] | Callable[[int], Any] | None
|
||||
argtypes: Sequence[type[_CData]]
|
||||
errcheck: _ECT
|
||||
@overload
|
||||
def __init__(self, address: int) -> None: ...
|
||||
@@ -120,15 +119,15 @@ class _NamedFuncPointer(_FuncPointer):
|
||||
class ArgumentError(Exception): ...
|
||||
|
||||
def CFUNCTYPE(
|
||||
restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> Type[_FuncPointer]: ...
|
||||
restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> type[_FuncPointer]: ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
def WINFUNCTYPE(
|
||||
restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> Type[_FuncPointer]: ...
|
||||
restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ...
|
||||
) -> type[_FuncPointer]: ...
|
||||
|
||||
def PYFUNCTYPE(restype: Type[_CData] | None, *argtypes: Type[_CData]) -> Type[_FuncPointer]: ...
|
||||
def PYFUNCTYPE(restype: type[_CData] | None, *argtypes: type[_CData]) -> type[_FuncPointer]: ...
|
||||
|
||||
class _CArgObject: ...
|
||||
|
||||
@@ -142,12 +141,12 @@ _CVoidPLike = _UnionT[_PointerLike, Array[Any], _CArgObject, int]
|
||||
_CVoidConstPLike = _UnionT[_CVoidPLike, bytes]
|
||||
|
||||
def addressof(obj: _CData) -> int: ...
|
||||
def alignment(obj_or_type: _CData | Type[_CData]) -> int: ...
|
||||
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
|
||||
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||
|
||||
_CastT = TypeVar("_CastT", bound=_CanCastTo)
|
||||
|
||||
def cast(obj: _CData | _CArgObject | int, typ: Type[_CastT]) -> _CastT: ...
|
||||
def cast(obj: _CData | _CArgObject | int, typ: type[_CastT]) -> _CastT: ...
|
||||
def create_string_buffer(init: int | bytes, size: int | None = ...) -> Array[c_char]: ...
|
||||
|
||||
c_buffer = create_string_buffer
|
||||
@@ -167,13 +166,13 @@ if sys.platform == "win32":
|
||||
|
||||
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]]: ...
|
||||
def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ...
|
||||
|
||||
# The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like
|
||||
# ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer,
|
||||
# it can be instantiated directly (to mimic the behavior of the real pointer function).
|
||||
class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
_type_: Type[_CT]
|
||||
_type_: type[_CT]
|
||||
contents: _CT
|
||||
def __init__(self, arg: _CT = ...) -> None: ...
|
||||
@overload
|
||||
@@ -191,7 +190,7 @@ def set_errno(value: int) -> int: ...
|
||||
if sys.platform == "win32":
|
||||
def set_last_error(value: int) -> int: ...
|
||||
|
||||
def sizeof(obj_or_type: _CData | Type[_CData]) -> int: ...
|
||||
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
|
||||
def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
@@ -252,7 +251,7 @@ class _CField:
|
||||
size: int
|
||||
|
||||
class _StructUnionMeta(_CDataMeta):
|
||||
_fields_: Sequence[tuple[str, Type[_CData]] | tuple[str, Type[_CData], int]]
|
||||
_fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]]
|
||||
_pack_: int
|
||||
_anonymous_: Sequence[str]
|
||||
def __getattr__(self, name: str) -> _CField: ...
|
||||
@@ -275,9 +274,9 @@ class Array(Generic[_CT], _CData):
|
||||
def _length_(self, value: int) -> None: ...
|
||||
@property
|
||||
@abstractmethod
|
||||
def _type_(self) -> Type[_CT]: ...
|
||||
def _type_(self) -> type[_CT]: ...
|
||||
@_type_.setter
|
||||
def _type_(self, value: Type[_CT]) -> None: ...
|
||||
def _type_(self, value: type[_CT]) -> None: ...
|
||||
raw: bytes # Note: only available if _CT == c_char
|
||||
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
|
||||
# TODO These methods cannot be annotated correctly at the moment.
|
||||
|
||||
Reference in New Issue
Block a user