mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-11 19:00:52 +08:00
stdlib: add __slots__ (#14611)
This commit is contained in:
@@ -6,21 +6,26 @@ from typing import Any
|
||||
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
|
||||
|
||||
class BaseProtocol:
|
||||
__slots__ = ()
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Exception | None) -> None: ...
|
||||
def pause_writing(self) -> None: ...
|
||||
def resume_writing(self) -> None: ...
|
||||
|
||||
class Protocol(BaseProtocol):
|
||||
# Need annotation or mypy will complain about 'Cannot determine type of "__slots__" in base class'
|
||||
__slots__: tuple[()] = ()
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> bool | None: ...
|
||||
|
||||
class BufferedProtocol(BaseProtocol):
|
||||
__slots__ = ()
|
||||
def get_buffer(self, sizehint: int) -> ReadableBuffer: ...
|
||||
def buffer_updated(self, nbytes: int) -> None: ...
|
||||
def eof_received(self) -> bool | None: ...
|
||||
|
||||
class DatagramProtocol(BaseProtocol):
|
||||
__slots__ = ()
|
||||
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
|
||||
# addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK.
|
||||
# Use tuple[str | Any, int] to not cause typechecking issues on most usual cases.
|
||||
@@ -30,6 +35,7 @@ class DatagramProtocol(BaseProtocol):
|
||||
def error_received(self, exc: Exception) -> None: ...
|
||||
|
||||
class SubprocessProtocol(BaseProtocol):
|
||||
__slots__: tuple[()] = ()
|
||||
def pipe_data_received(self, fd: int, data: bytes) -> None: ...
|
||||
def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
|
||||
def process_exited(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user