Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/websockets/__init__.py: 39%
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
3# Importing the typing module would conflict with websockets.typing.
4from typing import TYPE_CHECKING
6from .imports import lazy_import
7from .version import version as __version__ # noqa: F401
10__all__ = [
11 # .asyncio.client
12 "connect",
13 "unix_connect",
14 "ClientConnection",
15 # .asyncio.router
16 "route",
17 "unix_route",
18 "Router",
19 # .asyncio.server
20 "basic_auth",
21 "broadcast",
22 "serve",
23 "unix_serve",
24 "ServerConnection",
25 "Server",
26 # .client
27 "ClientProtocol",
28 # .datastructures
29 "Headers",
30 "HeadersLike",
31 "MultipleValuesError",
32 # .exceptions
33 "ConcurrencyError",
34 "ConnectionClosed",
35 "ConnectionClosedError",
36 "ConnectionClosedOK",
37 "DuplicateParameter",
38 "HeaderLineTooLong",
39 "InvalidHandshake",
40 "InvalidHeader",
41 "InvalidHeaderFormat",
42 "InvalidHeaderValue",
43 "InvalidMessage",
44 "InvalidMethod",
45 "InvalidOrigin",
46 "InvalidParameterName",
47 "InvalidParameterValue",
48 "InvalidProtocol",
49 "InvalidProxy",
50 "InvalidProxyMessage",
51 "InvalidProxyStatus",
52 "InvalidState",
53 "InvalidStatus",
54 "InvalidUpgrade",
55 "InvalidURI",
56 "NegotiationError",
57 "PayloadTooBig",
58 "ProtocolError",
59 "ProxyError",
60 "RequestLineTooLong",
61 "SecurityError",
62 "StatusLineTooLong",
63 "TooManyFragments",
64 "TooManyHeaders",
65 "WebSocketException",
66 # .frames
67 "Close",
68 "CloseCode",
69 "Frame",
70 "Opcode",
71 # .http11
72 "Request",
73 "Response",
74 # .protocol
75 "Protocol",
76 "Side",
77 "State",
78 # .server
79 "ServerProtocol",
80 # .typing
81 "Data",
82 "ExtensionName",
83 "ExtensionParameter",
84 "LoggerLike",
85 "StatusLike",
86 "Origin",
87 "Subprotocol",
88]
90# When type checking, import non-deprecated aliases eagerly. Else, import on demand.
91if TYPE_CHECKING:
92 from .asyncio.client import ClientConnection, connect, unix_connect
93 from .asyncio.router import Router, route, unix_route
94 from .asyncio.server import (
95 Server,
96 ServerConnection,
97 basic_auth,
98 broadcast,
99 serve,
100 unix_serve,
101 )
102 from .client import ClientProtocol
103 from .datastructures import Headers, HeadersLike, MultipleValuesError
104 from .exceptions import (
105 ConcurrencyError,
106 ConnectionClosed,
107 ConnectionClosedError,
108 ConnectionClosedOK,
109 DuplicateParameter,
110 HeaderLineTooLong,
111 InvalidHandshake,
112 InvalidHeader,
113 InvalidHeaderFormat,
114 InvalidHeaderValue,
115 InvalidMessage,
116 InvalidMethod,
117 InvalidOrigin,
118 InvalidParameterName,
119 InvalidParameterValue,
120 InvalidProtocol,
121 InvalidProxy,
122 InvalidProxyMessage,
123 InvalidProxyStatus,
124 InvalidState,
125 InvalidStatus,
126 InvalidUpgrade,
127 InvalidURI,
128 NegotiationError,
129 PayloadTooBig,
130 ProtocolError,
131 ProxyError,
132 RequestLineTooLong,
133 SecurityError,
134 StatusLineTooLong,
135 TooManyFragments,
136 TooManyHeaders,
137 WebSocketException,
138 )
139 from .frames import Close, CloseCode, Frame, Opcode
140 from .http11 import Request, Response
141 from .protocol import Protocol, Side, State
142 from .server import ServerProtocol
143 from .typing import (
144 Data,
145 ExtensionName,
146 ExtensionParameter,
147 LoggerLike,
148 Origin,
149 StatusLike,
150 Subprotocol,
151 )
152else:
153 lazy_import(
154 globals(),
155 aliases={
156 # .asyncio.client
157 "connect": ".asyncio.client",
158 "unix_connect": ".asyncio.client",
159 "ClientConnection": ".asyncio.client",
160 # .asyncio.router
161 "route": ".asyncio.router",
162 "unix_route": ".asyncio.router",
163 "Router": ".asyncio.router",
164 # .asyncio.server
165 "basic_auth": ".asyncio.server",
166 "broadcast": ".asyncio.server",
167 "serve": ".asyncio.server",
168 "unix_serve": ".asyncio.server",
169 "ServerConnection": ".asyncio.server",
170 "Server": ".asyncio.server",
171 # .client
172 "ClientProtocol": ".client",
173 # .datastructures
174 "Headers": ".datastructures",
175 "HeadersLike": ".datastructures",
176 "MultipleValuesError": ".datastructures",
177 # .exceptions
178 "ConcurrencyError": ".exceptions",
179 "ConnectionClosed": ".exceptions",
180 "ConnectionClosedError": ".exceptions",
181 "ConnectionClosedOK": ".exceptions",
182 "DuplicateParameter": ".exceptions",
183 "HeaderLineTooLong": ".exceptions",
184 "InvalidHandshake": ".exceptions",
185 "InvalidHeader": ".exceptions",
186 "InvalidHeaderFormat": ".exceptions",
187 "InvalidHeaderValue": ".exceptions",
188 "InvalidMessage": ".exceptions",
189 "InvalidMethod": ".exceptions",
190 "InvalidOrigin": ".exceptions",
191 "InvalidParameterName": ".exceptions",
192 "InvalidParameterValue": ".exceptions",
193 "InvalidProtocol": ".exceptions",
194 "InvalidProxy": ".exceptions",
195 "InvalidProxyMessage": ".exceptions",
196 "InvalidProxyStatus": ".exceptions",
197 "InvalidState": ".exceptions",
198 "InvalidStatus": ".exceptions",
199 "InvalidUpgrade": ".exceptions",
200 "InvalidURI": ".exceptions",
201 "NegotiationError": ".exceptions",
202 "PayloadTooBig": ".exceptions",
203 "ProtocolError": ".exceptions",
204 "ProxyError": ".exceptions",
205 "RequestLineTooLong": ".exceptions",
206 "SecurityError": ".exceptions",
207 "StatusLineTooLong": ".exceptions",
208 "TooManyFragments": ".exceptions",
209 "TooManyHeaders": ".exceptions",
210 "WebSocketException": ".exceptions",
211 # .frames
212 "Close": ".frames",
213 "CloseCode": ".frames",
214 "Frame": ".frames",
215 "Opcode": ".frames",
216 # .http11
217 "Request": ".http11",
218 "Response": ".http11",
219 # .protocol
220 "Protocol": ".protocol",
221 "Side": ".protocol",
222 "State": ".protocol",
223 # .server
224 "ServerProtocol": ".server",
225 # .typing
226 "Data": ".typing",
227 "ExtensionName": ".typing",
228 "ExtensionParameter": ".typing",
229 "LoggerLike": ".typing",
230 "Origin": ".typing",
231 "StatusLike": ".typing",
232 "Subprotocol": ".typing",
233 },
234 deprecated_aliases={
235 # deprecated in 14.0 - 2024-11-09
236 # .legacy.auth
237 "BasicAuthWebSocketServerProtocol": ".legacy.auth",
238 "basic_auth_protocol_factory": ".legacy.auth",
239 # .legacy.client
240 "WebSocketClientProtocol": ".legacy.client",
241 # .legacy.exceptions
242 "AbortHandshake": ".legacy.exceptions",
243 "InvalidStatusCode": ".legacy.exceptions",
244 "RedirectHandshake": ".legacy.exceptions",
245 "WebSocketProtocolError": ".legacy.exceptions",
246 # .legacy.protocol
247 "WebSocketCommonProtocol": ".legacy.protocol",
248 # .legacy.server
249 "WebSocketServer": ".legacy.server",
250 "WebSocketServerProtocol": ".legacy.server",
251 },
252 )