mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Add more defaults to the stdlib (#9606)
Continuing work towards #8988. The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are: - Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine) - Defaults in non-py311 branches - Defaults for float parameters - Defaults for overloads
This commit is contained in:
@@ -26,7 +26,7 @@ class _ConnectionBase:
|
||||
def recv_bytes(self, maxlength: int | None = None) -> bytes: ...
|
||||
def recv_bytes_into(self, buf: Any, offset: int = 0) -> int: ...
|
||||
def recv(self) -> Any: ...
|
||||
def poll(self, timeout: float | None = ...) -> bool: ...
|
||||
def poll(self, timeout: float | None = 0.0) -> bool: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
|
||||
@@ -66,4 +66,4 @@ if sys.platform != "win32":
|
||||
def Pipe(duplex: bool = True) -> tuple[Connection, Connection]: ...
|
||||
|
||||
else:
|
||||
def Pipe(duplex: bool = ...) -> tuple[PipeConnection, PipeConnection]: ...
|
||||
def Pipe(duplex: bool = True) -> tuple[PipeConnection, PipeConnection]: ...
|
||||
|
||||
@@ -54,7 +54,7 @@ class BaseContext:
|
||||
if sys.platform != "win32":
|
||||
def Pipe(self, duplex: bool = True) -> tuple[Connection, Connection]: ...
|
||||
else:
|
||||
def Pipe(self, duplex: bool = ...) -> tuple[PipeConnection, PipeConnection]: ...
|
||||
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection, PipeConnection]: ...
|
||||
|
||||
def Barrier(
|
||||
self, parties: int, action: Callable[..., object] | None = None, timeout: float | None = None
|
||||
@@ -86,24 +86,24 @@ class BaseContext:
|
||||
@overload
|
||||
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> _CT: ...
|
||||
@overload
|
||||
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = ...) -> SynchronizedBase[_CT]: ...
|
||||
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True) -> SynchronizedBase[_CT]: ...
|
||||
@overload
|
||||
def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = ...) -> SynchronizedBase[Any]: ...
|
||||
def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = True) -> SynchronizedBase[Any]: ...
|
||||
@overload
|
||||
def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ...
|
||||
def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True) -> Any: ...
|
||||
@overload
|
||||
def Array(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ...
|
||||
@overload
|
||||
def Array(
|
||||
self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = ...
|
||||
self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
|
||||
) -> SynchronizedArray[_CT]: ...
|
||||
@overload
|
||||
def Array(
|
||||
self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = ...
|
||||
self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
|
||||
) -> SynchronizedArray[Any]: ...
|
||||
@overload
|
||||
def Array(
|
||||
self, typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ...
|
||||
self, typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = True
|
||||
) -> Any: ...
|
||||
def freeze_support(self) -> None: ...
|
||||
def get_logger(self) -> Logger: ...
|
||||
@@ -124,14 +124,14 @@ class BaseContext:
|
||||
def get_context(self, method: str) -> BaseContext: ...
|
||||
else:
|
||||
@overload
|
||||
def get_context(self, method: None = ...) -> DefaultContext: ...
|
||||
def get_context(self, method: None = None) -> DefaultContext: ...
|
||||
@overload
|
||||
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@overload
|
||||
def get_context(self, method: str) -> BaseContext: ...
|
||||
|
||||
@overload
|
||||
def get_start_method(self, allow_none: Literal[False] = ...) -> str: ...
|
||||
def get_start_method(self, allow_none: Literal[False] = False) -> str: ...
|
||||
@overload
|
||||
def get_start_method(self, allow_none: bool) -> str | None: ...
|
||||
def set_start_method(self, method: str | None, force: bool = False) -> None: ...
|
||||
|
||||
@@ -23,7 +23,7 @@ class Connection:
|
||||
) -> None: ...
|
||||
def __init__(self, _in: Any, _out: Any) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def poll(self, timeout: float = ...) -> bool: ...
|
||||
def poll(self, timeout: float = 0.0) -> bool: ...
|
||||
|
||||
class Listener:
|
||||
_backlog_queue: Queue[Any] | None
|
||||
|
||||
@@ -27,7 +27,7 @@ if sys.platform != "win32":
|
||||
def rebuild_arena(size: int, dupfd: _SupportsDetach) -> Arena: ...
|
||||
|
||||
class Heap:
|
||||
def __init__(self, size: int = ...) -> None: ...
|
||||
def __init__(self, size: int = 4096) -> None: ...
|
||||
def free(self, block: _Block) -> None: ...
|
||||
def malloc(self, size: int) -> _Block: ...
|
||||
|
||||
|
||||
@@ -137,11 +137,15 @@ class BaseManager:
|
||||
serializer: str = "pickle",
|
||||
ctx: BaseContext | None = None,
|
||||
*,
|
||||
shutdown_timeout: float = ...,
|
||||
shutdown_timeout: float = 1.0,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self, address: Any | None = ..., authkey: bytes | None = ..., serializer: str = ..., ctx: BaseContext | None = ...
|
||||
self,
|
||||
address: Any | None = None,
|
||||
authkey: bytes | None = None,
|
||||
serializer: str = "pickle",
|
||||
ctx: BaseContext | None = None,
|
||||
) -> None: ...
|
||||
|
||||
def get_server(self) -> Server: ...
|
||||
|
||||
@@ -21,7 +21,7 @@ if sys.platform == "win32":
|
||||
|
||||
def __init__(self, process_obj: BaseProcess) -> None: ...
|
||||
def duplicate_for_child(self, handle: int) -> int: ...
|
||||
def wait(self, timeout: float | None = ...) -> int | None: ...
|
||||
def wait(self, timeout: float | None = None) -> int | None: ...
|
||||
def poll(self) -> int | None: ...
|
||||
def terminate(self) -> None: ...
|
||||
|
||||
|
||||
@@ -34,17 +34,17 @@ def dump(obj: Any, file: SupportsWrite[bytes], protocol: int | None = None) -> N
|
||||
if sys.platform == "win32":
|
||||
if sys.version_info >= (3, 8):
|
||||
def duplicate(
|
||||
handle: int, target_process: int | None = ..., inheritable: bool = ..., *, source_process: int | None = ...
|
||||
handle: int, target_process: int | None = None, inheritable: bool = False, *, source_process: int | None = None
|
||||
) -> int: ...
|
||||
else:
|
||||
def duplicate(handle: int, target_process: int | None = ..., inheritable: bool = ...) -> int: ...
|
||||
def duplicate(handle: int, target_process: int | None = None, inheritable: bool = False) -> int: ...
|
||||
|
||||
def steal_handle(source_pid: int, handle: int) -> int: ...
|
||||
def send_handle(conn: connection.PipeConnection, handle: int, destination_pid: int) -> None: ...
|
||||
def recv_handle(conn: connection.PipeConnection) -> int: ...
|
||||
|
||||
class DupHandle:
|
||||
def __init__(self, handle: int, access: int, pid: int | None = ...) -> None: ...
|
||||
def __init__(self, handle: int, access: int, pid: int | None = None) -> None: ...
|
||||
def detach(self) -> int: ...
|
||||
|
||||
else:
|
||||
|
||||
@@ -24,9 +24,9 @@ class SharedMemory:
|
||||
class ShareableList(Generic[_SLT]):
|
||||
shm: SharedMemory
|
||||
@overload
|
||||
def __init__(self, sequence: None = ..., *, name: str | None = ...) -> None: ...
|
||||
def __init__(self, sequence: None = None, *, name: str | None = None) -> None: ...
|
||||
@overload
|
||||
def __init__(self, sequence: Iterable[_SLT], *, name: str | None = ...) -> None: ...
|
||||
def __init__(self, sequence: Iterable[_SLT], *, name: str | None = None) -> None: ...
|
||||
def __getitem__(self, position: int) -> _SLT: ...
|
||||
def __setitem__(self, position: int, value: _SLT) -> None: ...
|
||||
def __reduce__(self: Self) -> tuple[Self, tuple[_SLT, ...]]: ...
|
||||
|
||||
@@ -21,56 +21,56 @@ def RawArray(typecode_or_type: type[_CT], size_or_initializer: int | Sequence[An
|
||||
@overload
|
||||
def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ...
|
||||
@overload
|
||||
def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ...
|
||||
def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = None) -> _CT: ...
|
||||
@overload
|
||||
def Value(
|
||||
typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ...
|
||||
typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True, ctx: BaseContext | None = None
|
||||
) -> SynchronizedBase[_CT]: ...
|
||||
@overload
|
||||
def Value(
|
||||
typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ...
|
||||
typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = True, ctx: BaseContext | None = None
|
||||
) -> SynchronizedBase[Any]: ...
|
||||
@overload
|
||||
def Value(
|
||||
typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ...
|
||||
typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True, ctx: BaseContext | None = None
|
||||
) -> Any: ...
|
||||
@overload
|
||||
def Array(
|
||||
typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ...
|
||||
typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = None
|
||||
) -> _CT: ...
|
||||
@overload
|
||||
def Array(
|
||||
typecode_or_type: type[_CT],
|
||||
size_or_initializer: int | Sequence[Any],
|
||||
*,
|
||||
lock: Literal[True] | _LockLike = ...,
|
||||
ctx: BaseContext | None = ...,
|
||||
lock: Literal[True] | _LockLike = True,
|
||||
ctx: BaseContext | None = None,
|
||||
) -> SynchronizedArray[_CT]: ...
|
||||
@overload
|
||||
def Array(
|
||||
typecode_or_type: str,
|
||||
size_or_initializer: int | Sequence[Any],
|
||||
*,
|
||||
lock: Literal[True] | _LockLike = ...,
|
||||
ctx: BaseContext | None = ...,
|
||||
lock: Literal[True] | _LockLike = True,
|
||||
ctx: BaseContext | None = None,
|
||||
) -> SynchronizedArray[Any]: ...
|
||||
@overload
|
||||
def Array(
|
||||
typecode_or_type: str | type[_CData],
|
||||
size_or_initializer: int | Sequence[Any],
|
||||
*,
|
||||
lock: bool | _LockLike = ...,
|
||||
ctx: BaseContext | None = ...,
|
||||
lock: bool | _LockLike = True,
|
||||
ctx: BaseContext | None = None,
|
||||
) -> Any: ...
|
||||
def copy(obj: _CT) -> _CT: ...
|
||||
@overload
|
||||
def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = ..., ctx: Any | None = ...) -> Synchronized[_T]: ...
|
||||
def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = None, ctx: Any | None = None) -> Synchronized[_T]: ...
|
||||
@overload
|
||||
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedString: ...
|
||||
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedString: ...
|
||||
@overload
|
||||
def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedArray[_CT]: ...
|
||||
def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedArray[_CT]: ...
|
||||
@overload
|
||||
def synchronized(obj: _CT, lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedBase[_CT]: ...
|
||||
def synchronized(obj: _CT, lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedBase[_CT]: ...
|
||||
|
||||
class _AcquireFunc(Protocol):
|
||||
def __call__(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user