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

18 statements  

1from __future__ import annotations 

2 

3# Importing the typing module would conflict with websockets.typing. 

4from typing import TYPE_CHECKING 

5 

6from .imports import lazy_import 

7from .version import version as __version__ # noqa: F401 

8 

9 

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 "InvalidHandshake", 

39 "InvalidHeader", 

40 "InvalidHeaderFormat", 

41 "InvalidHeaderValue", 

42 "InvalidMessage", 

43 "InvalidOrigin", 

44 "InvalidParameterName", 

45 "InvalidParameterValue", 

46 "InvalidProxy", 

47 "InvalidProxyMessage", 

48 "InvalidProxyStatus", 

49 "InvalidState", 

50 "InvalidStatus", 

51 "InvalidUpgrade", 

52 "InvalidURI", 

53 "NegotiationError", 

54 "PayloadTooBig", 

55 "ProtocolError", 

56 "ProxyError", 

57 "SecurityError", 

58 "WebSocketException", 

59 # .frames 

60 "Close", 

61 "CloseCode", 

62 "Frame", 

63 "Opcode", 

64 # .http11 

65 "Request", 

66 "Response", 

67 # .protocol 

68 "Protocol", 

69 "Side", 

70 "State", 

71 # .server 

72 "ServerProtocol", 

73 # .typing 

74 "Data", 

75 "ExtensionName", 

76 "ExtensionParameter", 

77 "LoggerLike", 

78 "StatusLike", 

79 "Origin", 

80 "Subprotocol", 

81] 

82 

83# When type checking, import non-deprecated aliases eagerly. Else, import on demand. 

84if TYPE_CHECKING: 

85 from .asyncio.client import ClientConnection, connect, unix_connect 

86 from .asyncio.router import Router, route, unix_route 

87 from .asyncio.server import ( 

88 Server, 

89 ServerConnection, 

90 basic_auth, 

91 broadcast, 

92 serve, 

93 unix_serve, 

94 ) 

95 from .client import ClientProtocol 

96 from .datastructures import Headers, HeadersLike, MultipleValuesError 

97 from .exceptions import ( 

98 ConcurrencyError, 

99 ConnectionClosed, 

100 ConnectionClosedError, 

101 ConnectionClosedOK, 

102 DuplicateParameter, 

103 InvalidHandshake, 

104 InvalidHeader, 

105 InvalidHeaderFormat, 

106 InvalidHeaderValue, 

107 InvalidMessage, 

108 InvalidOrigin, 

109 InvalidParameterName, 

110 InvalidParameterValue, 

111 InvalidProxy, 

112 InvalidProxyMessage, 

113 InvalidProxyStatus, 

114 InvalidState, 

115 InvalidStatus, 

116 InvalidUpgrade, 

117 InvalidURI, 

118 NegotiationError, 

119 PayloadTooBig, 

120 ProtocolError, 

121 ProxyError, 

122 SecurityError, 

123 WebSocketException, 

124 ) 

125 from .frames import Close, CloseCode, Frame, Opcode 

126 from .http11 import Request, Response 

127 from .protocol import Protocol, Side, State 

128 from .server import ServerProtocol 

129 from .typing import ( 

130 Data, 

131 ExtensionName, 

132 ExtensionParameter, 

133 LoggerLike, 

134 Origin, 

135 StatusLike, 

136 Subprotocol, 

137 ) 

138else: 

139 lazy_import( 

140 globals(), 

141 aliases={ 

142 # .asyncio.client 

143 "connect": ".asyncio.client", 

144 "unix_connect": ".asyncio.client", 

145 "ClientConnection": ".asyncio.client", 

146 # .asyncio.router 

147 "route": ".asyncio.router", 

148 "unix_route": ".asyncio.router", 

149 "Router": ".asyncio.router", 

150 # .asyncio.server 

151 "basic_auth": ".asyncio.server", 

152 "broadcast": ".asyncio.server", 

153 "serve": ".asyncio.server", 

154 "unix_serve": ".asyncio.server", 

155 "ServerConnection": ".asyncio.server", 

156 "Server": ".asyncio.server", 

157 # .client 

158 "ClientProtocol": ".client", 

159 # .datastructures 

160 "Headers": ".datastructures", 

161 "HeadersLike": ".datastructures", 

162 "MultipleValuesError": ".datastructures", 

163 # .exceptions 

164 "ConcurrencyError": ".exceptions", 

165 "ConnectionClosed": ".exceptions", 

166 "ConnectionClosedError": ".exceptions", 

167 "ConnectionClosedOK": ".exceptions", 

168 "DuplicateParameter": ".exceptions", 

169 "InvalidHandshake": ".exceptions", 

170 "InvalidHeader": ".exceptions", 

171 "InvalidHeaderFormat": ".exceptions", 

172 "InvalidHeaderValue": ".exceptions", 

173 "InvalidMessage": ".exceptions", 

174 "InvalidOrigin": ".exceptions", 

175 "InvalidParameterName": ".exceptions", 

176 "InvalidParameterValue": ".exceptions", 

177 "InvalidProxy": ".exceptions", 

178 "InvalidProxyMessage": ".exceptions", 

179 "InvalidProxyStatus": ".exceptions", 

180 "InvalidState": ".exceptions", 

181 "InvalidStatus": ".exceptions", 

182 "InvalidUpgrade": ".exceptions", 

183 "InvalidURI": ".exceptions", 

184 "NegotiationError": ".exceptions", 

185 "PayloadTooBig": ".exceptions", 

186 "ProtocolError": ".exceptions", 

187 "ProxyError": ".exceptions", 

188 "SecurityError": ".exceptions", 

189 "WebSocketException": ".exceptions", 

190 # .frames 

191 "Close": ".frames", 

192 "CloseCode": ".frames", 

193 "Frame": ".frames", 

194 "Opcode": ".frames", 

195 # .http11 

196 "Request": ".http11", 

197 "Response": ".http11", 

198 # .protocol 

199 "Protocol": ".protocol", 

200 "Side": ".protocol", 

201 "State": ".protocol", 

202 # .server 

203 "ServerProtocol": ".server", 

204 # .typing 

205 "Data": ".typing", 

206 "ExtensionName": ".typing", 

207 "ExtensionParameter": ".typing", 

208 "LoggerLike": ".typing", 

209 "Origin": ".typing", 

210 "StatusLike": ".typing", 

211 "Subprotocol": ".typing", 

212 }, 

213 deprecated_aliases={ 

214 # deprecated in 9.0 - 2021-09-01 

215 "framing": ".legacy", 

216 "handshake": ".legacy", 

217 "parse_uri": ".uri", 

218 "WebSocketURI": ".uri", 

219 # deprecated in 14.0 - 2024-11-09 

220 # .legacy.auth 

221 "BasicAuthWebSocketServerProtocol": ".legacy.auth", 

222 "basic_auth_protocol_factory": ".legacy.auth", 

223 # .legacy.client 

224 "WebSocketClientProtocol": ".legacy.client", 

225 # .legacy.exceptions 

226 "AbortHandshake": ".legacy.exceptions", 

227 "InvalidStatusCode": ".legacy.exceptions", 

228 "RedirectHandshake": ".legacy.exceptions", 

229 "WebSocketProtocolError": ".legacy.exceptions", 

230 # .legacy.protocol 

231 "WebSocketCommonProtocol": ".legacy.protocol", 

232 # .legacy.server 

233 "WebSocketServer": ".legacy.server", 

234 "WebSocketServerProtocol": ".legacy.server", 

235 }, 

236 )