Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/websockets/typing.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3import http
4import logging
5from typing import Any, NewType, Sequence
8__all__ = [
9 "Data",
10 "LoggerLike",
11 "StatusLike",
12 "Origin",
13 "Subprotocol",
14 "ExtensionName",
15 "ExtensionParameter",
16]
19# Public types used in the signature of public APIs
21Data = str | bytes
22"""Types supported in a WebSocket message:
23:class:`str` for a Text_ frame, :class:`bytes` for a Binary_ frame.
25.. _Text: https://datatracker.ietf.org/doc/html/rfc6455#section-5.6
26.. _Binary : https://datatracker.ietf.org/doc/html/rfc6455#section-5.6
28"""
30BytesLike = bytes | bytearray | memoryview
31"""Types accepted where :class:`bytes` is expected."""
33DataLike = str | bytes | bytearray | memoryview
34"""Types accepted where :class:`Data` is expected."""
36LoggerLike = logging.Logger | logging.LoggerAdapter[Any]
37"""Types accepted where a :class:`~logging.Logger` is expected."""
40StatusLike = http.HTTPStatus | int
41"""
42Types accepted where an :class:`~http.HTTPStatus` is expected."""
45Origin = NewType("Origin", str)
46"""Value of a ``Origin`` header."""
49Subprotocol = NewType("Subprotocol", str)
50"""Subprotocol in a ``Sec-WebSocket-Protocol`` header."""
53ExtensionName = NewType("ExtensionName", str)
54"""Name of a WebSocket extension."""
56ExtensionParameter = tuple[str, str | None]
57"""Parameter of a WebSocket extension."""
60# Private types
62ExtensionHeader = tuple[ExtensionName, Sequence[ExtensionParameter]]
63"""Extension in a ``Sec-WebSocket-Extensions`` header."""
66ConnectionOption = NewType("ConnectionOption", str)
67"""Connection option in a ``Connection`` header."""
70UpgradeProtocol = NewType("UpgradeProtocol", str)
71"""Upgrade protocol in an ``Upgrade`` header."""