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
5import os
6from typing import Any, NewType, Sequence
9__all__ = [
10 "Data",
11 "LoggerLike",
12 "StatusLike",
13 "Origin",
14 "Subprotocol",
15 "ExtensionName",
16 "ExtensionParameter",
17]
20# Public types used in the signature of public APIs
22Data = str | bytes
23"""Types supported in a WebSocket message:
24:class:`str` for a Text_ frame, :class:`bytes` for a Binary_ frame.
26.. _Text: https://datatracker.ietf.org/doc/html/rfc6455#section-5.6
27.. _Binary : https://datatracker.ietf.org/doc/html/rfc6455#section-5.6
29"""
31BytesLike = bytes | bytearray | memoryview
32"""Types accepted where :class:`bytes` is expected."""
34DataLike = str | bytes | bytearray | memoryview
35"""Types accepted where :class:`Data` is expected."""
37LoggerLike = logging.Logger | logging.LoggerAdapter[Any]
38"""Types accepted where a :class:`~logging.Logger` is expected."""
40PathLike = str | bytes | os.PathLike[str] | os.PathLike[bytes]
41"""Types accepted where a filesystem path is expected."""
43StatusLike = http.HTTPStatus | int
44"""Types accepted where an :class:`~http.HTTPStatus` is expected."""
47Origin = NewType("Origin", str)
48"""Value of a ``Origin`` header."""
51Subprotocol = NewType("Subprotocol", str)
52"""Subprotocol in a ``Sec-WebSocket-Protocol`` header."""
55ExtensionName = NewType("ExtensionName", str)
56"""Name of a WebSocket extension."""
58ExtensionParameter = tuple[str, str | None]
59"""Parameter of a WebSocket extension."""
62# Private types
64ExtensionHeader = tuple[ExtensionName, Sequence[ExtensionParameter]]
65"""Extension in a ``Sec-WebSocket-Extensions`` header."""
68ConnectionOption = NewType("ConnectionOption", str)
69"""Connection option in a ``Connection`` header."""
72UpgradeProtocol = NewType("UpgradeProtocol", str)
73"""Upgrade protocol in an ``Upgrade`` header."""