Types

websockets.typing.Data = str | bytes

Types supported in a WebSocket message: str for a Text frame, bytes for a Binary frame.

websockets.typing.BytesLike = bytes | bytearray | memoryview

Types accepted where bytes is expected.

websockets.typing.DataLike = str | bytes | bytearray | memoryview

Types accepted where Data is expected.

websockets.typing.LoggerLike = logging.Logger | logging.LoggerAdapter

Types accepted where a Logger is expected.

websockets.typing.StatusLike = http.HTTPStatus | int

Types accepted where an HTTPStatus is expected.

websockets.typing.Origin = websockets.typing.Origin

Value of a Origin header.

websockets.typing.Subprotocol = websockets.typing.Subprotocol

Subprotocol in a Sec-WebSocket-Protocol header.

websockets.typing.ExtensionName = websockets.typing.ExtensionName

Name of a WebSocket extension.

websockets.typing.ExtensionParameter

Parameter of a WebSocket extension.

alias of tuple[str, str | None]

websockets.protocol.Event = websockets.http11.Request | websockets.http11.Response | websockets.frames.Frame

Events that events_received() may return.

websockets.datastructures.HeadersLike = websockets.datastructures.Headers | collections.abc.Mapping[str, str] | collections.abc.Iterable[tuple[str, str]] | websockets.datastructures.SupportsKeysAndGetItem

Types accepted where Headers is expected.

In addition to Headers itself, this includes dict-like types where both keys and values are str.

websockets.datastructures.SupportsKeysAndGetItem = <class 'websockets.datastructures.SupportsKeysAndGetItem'>[source]

Dict-like types with keys() -> str and __getitem__(key: str) -> str methods.