| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- from __future__ import annotations
- # Importing the typing module would conflict with websockets.typing.
- from typing import TYPE_CHECKING
- from .imports import lazy_import
- from .version import version as __version__ # noqa: F401
- __all__ = [
- # .asyncio.client
- "connect",
- "unix_connect",
- "ClientConnection",
- # .asyncio.router
- "route",
- "unix_route",
- "Router",
- # .asyncio.server
- "basic_auth",
- "broadcast",
- "serve",
- "unix_serve",
- "ServerConnection",
- "Server",
- # .client
- "ClientProtocol",
- # .datastructures
- "Headers",
- "HeadersLike",
- "MultipleValuesError",
- # .exceptions
- "ConcurrencyError",
- "ConnectionClosed",
- "ConnectionClosedError",
- "ConnectionClosedOK",
- "DuplicateParameter",
- "InvalidHandshake",
- "InvalidHeader",
- "InvalidHeaderFormat",
- "InvalidHeaderValue",
- "InvalidMessage",
- "InvalidOrigin",
- "InvalidParameterName",
- "InvalidParameterValue",
- "InvalidProxy",
- "InvalidProxyMessage",
- "InvalidProxyStatus",
- "InvalidState",
- "InvalidStatus",
- "InvalidUpgrade",
- "InvalidURI",
- "NegotiationError",
- "PayloadTooBig",
- "ProtocolError",
- "ProxyError",
- "SecurityError",
- "WebSocketException",
- # .frames
- "Close",
- "CloseCode",
- "Frame",
- "Opcode",
- # .http11
- "Request",
- "Response",
- # .protocol
- "Protocol",
- "Side",
- "State",
- # .server
- "ServerProtocol",
- # .typing
- "Data",
- "ExtensionName",
- "ExtensionParameter",
- "LoggerLike",
- "StatusLike",
- "Origin",
- "Subprotocol",
- ]
- # When type checking, import non-deprecated aliases eagerly. Else, import on demand.
- if TYPE_CHECKING:
- from .asyncio.client import ClientConnection, connect, unix_connect
- from .asyncio.router import Router, route, unix_route
- from .asyncio.server import (
- Server,
- ServerConnection,
- basic_auth,
- broadcast,
- serve,
- unix_serve,
- )
- from .client import ClientProtocol
- from .datastructures import Headers, HeadersLike, MultipleValuesError
- from .exceptions import (
- ConcurrencyError,
- ConnectionClosed,
- ConnectionClosedError,
- ConnectionClosedOK,
- DuplicateParameter,
- InvalidHandshake,
- InvalidHeader,
- InvalidHeaderFormat,
- InvalidHeaderValue,
- InvalidMessage,
- InvalidOrigin,
- InvalidParameterName,
- InvalidParameterValue,
- InvalidProxy,
- InvalidProxyMessage,
- InvalidProxyStatus,
- InvalidState,
- InvalidStatus,
- InvalidUpgrade,
- InvalidURI,
- NegotiationError,
- PayloadTooBig,
- ProtocolError,
- ProxyError,
- SecurityError,
- WebSocketException,
- )
- from .frames import Close, CloseCode, Frame, Opcode
- from .http11 import Request, Response
- from .protocol import Protocol, Side, State
- from .server import ServerProtocol
- from .typing import (
- Data,
- ExtensionName,
- ExtensionParameter,
- LoggerLike,
- Origin,
- StatusLike,
- Subprotocol,
- )
- else:
- lazy_import(
- globals(),
- aliases={
- # .asyncio.client
- "connect": ".asyncio.client",
- "unix_connect": ".asyncio.client",
- "ClientConnection": ".asyncio.client",
- # .asyncio.router
- "route": ".asyncio.router",
- "unix_route": ".asyncio.router",
- "Router": ".asyncio.router",
- # .asyncio.server
- "basic_auth": ".asyncio.server",
- "broadcast": ".asyncio.server",
- "serve": ".asyncio.server",
- "unix_serve": ".asyncio.server",
- "ServerConnection": ".asyncio.server",
- "Server": ".asyncio.server",
- # .client
- "ClientProtocol": ".client",
- # .datastructures
- "Headers": ".datastructures",
- "HeadersLike": ".datastructures",
- "MultipleValuesError": ".datastructures",
- # .exceptions
- "ConcurrencyError": ".exceptions",
- "ConnectionClosed": ".exceptions",
- "ConnectionClosedError": ".exceptions",
- "ConnectionClosedOK": ".exceptions",
- "DuplicateParameter": ".exceptions",
- "InvalidHandshake": ".exceptions",
- "InvalidHeader": ".exceptions",
- "InvalidHeaderFormat": ".exceptions",
- "InvalidHeaderValue": ".exceptions",
- "InvalidMessage": ".exceptions",
- "InvalidOrigin": ".exceptions",
- "InvalidParameterName": ".exceptions",
- "InvalidParameterValue": ".exceptions",
- "InvalidProxy": ".exceptions",
- "InvalidProxyMessage": ".exceptions",
- "InvalidProxyStatus": ".exceptions",
- "InvalidState": ".exceptions",
- "InvalidStatus": ".exceptions",
- "InvalidUpgrade": ".exceptions",
- "InvalidURI": ".exceptions",
- "NegotiationError": ".exceptions",
- "PayloadTooBig": ".exceptions",
- "ProtocolError": ".exceptions",
- "ProxyError": ".exceptions",
- "SecurityError": ".exceptions",
- "WebSocketException": ".exceptions",
- # .frames
- "Close": ".frames",
- "CloseCode": ".frames",
- "Frame": ".frames",
- "Opcode": ".frames",
- # .http11
- "Request": ".http11",
- "Response": ".http11",
- # .protocol
- "Protocol": ".protocol",
- "Side": ".protocol",
- "State": ".protocol",
- # .server
- "ServerProtocol": ".server",
- # .typing
- "Data": ".typing",
- "ExtensionName": ".typing",
- "ExtensionParameter": ".typing",
- "LoggerLike": ".typing",
- "Origin": ".typing",
- "StatusLike": ".typing",
- "Subprotocol": ".typing",
- },
- deprecated_aliases={
- # deprecated in 9.0 - 2021-09-01
- "framing": ".legacy",
- "handshake": ".legacy",
- "parse_uri": ".uri",
- "WebSocketURI": ".uri",
- # deprecated in 14.0 - 2024-11-09
- # .legacy.auth
- "BasicAuthWebSocketServerProtocol": ".legacy.auth",
- "basic_auth_protocol_factory": ".legacy.auth",
- # .legacy.client
- "WebSocketClientProtocol": ".legacy.client",
- # .legacy.exceptions
- "AbortHandshake": ".legacy.exceptions",
- "InvalidStatusCode": ".legacy.exceptions",
- "RedirectHandshake": ".legacy.exceptions",
- "WebSocketProtocolError": ".legacy.exceptions",
- # .legacy.protocol
- "WebSocketCommonProtocol": ".legacy.protocol",
- # .legacy.server
- "WebSocketServer": ".legacy.server",
- "WebSocketServerProtocol": ".legacy.server",
- },
- )
|