mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Make the return type of multiprocessing.connection.Pipe more precise (#8706)
The precise return type depends on the platform. Link to implementation:
68fb03249f/Lib/multiprocessing/connection.py (L518)
Now users no longer need to use the internal-looking class
`_ConnectionBase` in annotations, at least in code that doesn't
need to be cross-platform.
This commit is contained in:
@@ -58,4 +58,12 @@ def wait(
|
||||
object_list: Iterable[Connection | socket.socket | int], timeout: float | None = ...
|
||||
) -> list[Connection | socket.socket | int]: ...
|
||||
def Client(address: _Address, family: str | None = ..., authkey: bytes | None = ...) -> Connection: ...
|
||||
def Pipe(duplex: bool = ...) -> tuple[_ConnectionBase, _ConnectionBase]: ...
|
||||
|
||||
# N.B. Keep this in sync with multiprocessing.context.BaseContext.Pipe.
|
||||
# _ConnectionBase is the common base class of Connection and PipeConnection
|
||||
# and can be used in cross-platform code.
|
||||
if sys.platform != "win32":
|
||||
def Pipe(duplex: bool = ...) -> tuple[Connection, Connection]: ...
|
||||
|
||||
else:
|
||||
def Pipe(duplex: bool = ...) -> tuple[PipeConnection, PipeConnection]: ...
|
||||
|
||||
Reference in New Issue
Block a user