Rework socket (#5545)

* Extract _socket.pyi from socket.pyi.
* Extract _socket.socket from socket.socket.
* Fix socket.family annotation.
* Annotate SocketIO properly.
* SocketType is an alias of _socket.socket.
* Sort items in socket.pyi in the same order as in socket.py.
* Remove socket.EINTR.
* Use _typeshed.WriteableBuffer instead of custom alias.
* Add errorTab (Windows only).
* Add _socket.dup().
* Mark positional-only argments.
* Remove constructors from socket exceptions.
* socket.timeout is an alias for TimeoutError, starting with Python 3.10.
* Use PEP 604 in changed lines.
* Add alias for fileno arguments.
* getaddrinfo() port can be bytes.
* Explicitly override some SSLSocket methods.
* Allow ReadableBuffer in _CMSG arguments.
This commit is contained in:
Sebastian Rittau
2021-05-30 20:17:33 +02:00
committed by GitHub
parent ee4d9fb106
commit 6ee67483a3
15 changed files with 1245 additions and 754 deletions

View File

@@ -5,7 +5,7 @@ import sys
from _typeshed import StrPath
from collections.abc import Callable
from logging import FileHandler, Handler, LogRecord
from socket import SocketKind, SocketType
from socket import SocketKind, socket
from typing import Any, ClassVar, Optional, Pattern, Union
if sys.version_info >= (3, 7):
@@ -120,20 +120,20 @@ class SocketHandler(Handler):
host: str # undocumented
port: Optional[int] # undocumented
address: Union[tuple[str, int], str] # undocumented
sock: Optional[SocketType] # undocumented
sock: Optional[socket] # undocumented
closeOnError: bool # undocumented
retryTime: Optional[float] # undocumented
retryStart: float # undocumented
retryFactor: float # undocumented
retryMax: float # undocumented
def __init__(self, host: str, port: Optional[int]) -> None: ...
def makeSocket(self, timeout: float = ...) -> SocketType: ... # timeout is undocumented
def makeSocket(self, timeout: float = ...) -> socket: ... # timeout is undocumented
def makePickle(self, record: LogRecord) -> bytes: ...
def send(self, s: bytes) -> None: ...
def createSocket(self) -> None: ...
class DatagramHandler(SocketHandler):
def makeSocket(self) -> SocketType: ... # type: ignore
def makeSocket(self) -> socket: ... # type: ignore
class SysLogHandler(Handler):
LOG_EMERG: int