Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/httpcore/__init__.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

19 statements  

1from ._api import request, stream 

2from ._async import ( 

3 AsyncConnectionInterface, 

4 AsyncConnectionPool, 

5 AsyncHTTP2Connection, 

6 AsyncHTTP11Connection, 

7 AsyncHTTPConnection, 

8 AsyncHTTPProxy, 

9 AsyncSOCKSProxy, 

10) 

11from ._backends.base import ( 

12 SOCKET_OPTION, 

13 AsyncNetworkBackend, 

14 AsyncNetworkStream, 

15 NetworkBackend, 

16 NetworkStream, 

17) 

18from ._backends.mock import AsyncMockBackend, AsyncMockStream, MockBackend, MockStream 

19from ._backends.sync import SyncBackend 

20from ._exceptions import ( 

21 ConnectError, 

22 ConnectionNotAvailable, 

23 ConnectTimeout, 

24 LocalProtocolError, 

25 NetworkError, 

26 PoolTimeout, 

27 ProtocolError, 

28 ProxyError, 

29 ReadError, 

30 ReadTimeout, 

31 RemoteProtocolError, 

32 TimeoutException, 

33 UnsupportedProtocol, 

34 WriteError, 

35 WriteTimeout, 

36) 

37from ._models import URL, Origin, Request, Response 

38from ._ssl import default_ssl_context 

39from ._sync import ( 

40 ConnectionInterface, 

41 ConnectionPool, 

42 HTTP2Connection, 

43 HTTP11Connection, 

44 HTTPConnection, 

45 HTTPProxy, 

46 SOCKSProxy, 

47) 

48 

49# The 'httpcore.AnyIOBackend' class is conditional on 'anyio' being installed. 

50try: 

51 from ._backends.anyio import AnyIOBackend 

52except ImportError: # pragma: nocover 

53 

54 class AnyIOBackend: # type: ignore 

55 def __init__(self, *args, **kwargs): # type: ignore 

56 msg = ( 

57 "Attempted to use 'httpcore.AnyIOBackend' but 'anyio' is not installed." 

58 ) 

59 raise RuntimeError(msg) 

60 

61 

62# The 'httpcore.TrioBackend' class is conditional on 'trio' being installed. 

63try: 

64 from ._backends.trio import TrioBackend 

65except ImportError: # pragma: nocover 

66 

67 class TrioBackend: # type: ignore 

68 def __init__(self, *args, **kwargs): # type: ignore 

69 msg = "Attempted to use 'httpcore.TrioBackend' but 'trio' is not installed." 

70 raise RuntimeError(msg) 

71 

72 

73__all__ = [ 

74 # top-level requests 

75 "request", 

76 "stream", 

77 # models 

78 "Origin", 

79 "URL", 

80 "Request", 

81 "Response", 

82 # async 

83 "AsyncHTTPConnection", 

84 "AsyncConnectionPool", 

85 "AsyncHTTPProxy", 

86 "AsyncHTTP11Connection", 

87 "AsyncHTTP2Connection", 

88 "AsyncConnectionInterface", 

89 "AsyncSOCKSProxy", 

90 # sync 

91 "HTTPConnection", 

92 "ConnectionPool", 

93 "HTTPProxy", 

94 "HTTP11Connection", 

95 "HTTP2Connection", 

96 "ConnectionInterface", 

97 "SOCKSProxy", 

98 # network backends, implementations 

99 "SyncBackend", 

100 "AnyIOBackend", 

101 "TrioBackend", 

102 # network backends, mock implementations 

103 "AsyncMockBackend", 

104 "AsyncMockStream", 

105 "MockBackend", 

106 "MockStream", 

107 # network backends, interface 

108 "AsyncNetworkStream", 

109 "AsyncNetworkBackend", 

110 "NetworkStream", 

111 "NetworkBackend", 

112 # util 

113 "default_ssl_context", 

114 "SOCKET_OPTION", 

115 # exceptions 

116 "ConnectionNotAvailable", 

117 "ProxyError", 

118 "ProtocolError", 

119 "LocalProtocolError", 

120 "RemoteProtocolError", 

121 "UnsupportedProtocol", 

122 "TimeoutException", 

123 "PoolTimeout", 

124 "ConnectTimeout", 

125 "ReadTimeout", 

126 "WriteTimeout", 

127 "NetworkError", 

128 "ConnectError", 

129 "ReadError", 

130 "WriteError", 

131] 

132 

133__version__ = "1.0.5" 

134 

135 

136__locals = locals() 

137for __name in __all__: 

138 if not __name.startswith("__"): 

139 setattr(__locals[__name], "__module__", "httpcore") # noqa