1
- from typing import Any
1
+ import queue
2
+ from _typeshed import Self
3
+ from collections .abc import Mapping
4
+ from logging import Logger
5
+ from types import TracebackType
6
+ from typing import Any , ClassVar
7
+ from typing_extensions import Literal , TypeAlias
2
8
3
9
from . import connection , exceptions , request , response
4
10
from .connection import BaseSSLError as BaseSSLError , ConnectionError as ConnectionError , HTTPException as HTTPException
5
11
from .packages import ssl_match_hostname
6
- from .util import connection as _connection , retry , timeout , url
12
+ from .util import Url , connection as _connection , queue as urllib3queue , retry , timeout , url
7
13
8
14
ClosedPoolError = exceptions .ClosedPoolError
9
15
ProtocolError = exceptions .ProtocolError
@@ -29,48 +35,54 @@ Retry = retry.Retry
29
35
Timeout = timeout .Timeout
30
36
get_host = url .get_host
31
37
38
+ _Timeout : TypeAlias = Timeout | float
39
+ _Retries : TypeAlias = Retry | bool | int
40
+
32
41
xrange : Any
33
- log : Any
42
+ log : Logger
34
43
35
44
class ConnectionPool :
36
- scheme : Any
37
- QueueCls : Any
38
- host : Any
39
- port : Any
40
- def __init__ (self , host , port = ...) -> None : ...
41
- def __enter__ (self ): ...
42
- def __exit__ (self , exc_type , exc_val , exc_tb ): ...
43
- def close (self ): ...
45
+ scheme : ClassVar [str | None ]
46
+ QueueCls : ClassVar [type [queue .Queue [Any ]]]
47
+ host : str
48
+ port : int | None
49
+ def __init__ (self , host : str , port : int | None = ...) -> None : ...
50
+ def __enter__ (self : Self ) -> Self : ...
51
+ def __exit__ (
52
+ self , exc_type : type [BaseException ] | None , exc_val : BaseException | None , exc_tb : TracebackType | None
53
+ ) -> Literal [False ]: ...
54
+ def close (self ) -> None : ...
44
55
45
56
class HTTPConnectionPool (ConnectionPool , RequestMethods ):
46
- scheme : Any
47
- ConnectionCls : Any
48
- strict : Any
49
- timeout : Any
50
- retries : Any
51
- pool : Any
52
- block : Any
53
- proxy : Any
54
- proxy_headers : Any
55
- num_connections : Any
56
- num_requests : Any
57
+ scheme : ClassVar [str ]
58
+ ConnectionCls : ClassVar [type [HTTPConnection | HTTPSConnection ]]
59
+ ResponseCls : ClassVar [type [HTTPResponse ]]
60
+ strict : bool
61
+ timeout : _Timeout
62
+ retries : _Retries | None
63
+ pool : urllib3queue .LifoQueue | None
64
+ block : bool
65
+ proxy : Url | None
66
+ proxy_headers : Mapping [str , str ]
67
+ num_connections : int
68
+ num_requests : int
57
69
conn_kw : Any
58
70
def __init__ (
59
71
self ,
60
- host ,
61
- port = ...,
62
- strict = ...,
63
- timeout = ...,
64
- maxsize = ...,
65
- block = ...,
66
- headers = ...,
67
- retries = ...,
68
- _proxy = ...,
69
- _proxy_headers = ...,
72
+ host : str ,
73
+ port : int | None = ...,
74
+ strict : bool = ...,
75
+ timeout : _Timeout = ...,
76
+ maxsize : int = ...,
77
+ block : bool = ...,
78
+ headers : Mapping [ str , str ] | None = ...,
79
+ retries : _Retries | None = ...,
80
+ _proxy : Url | None = ...,
81
+ _proxy_headers : Mapping [ str , str ] | None = ...,
70
82
** conn_kw ,
71
83
) -> None : ...
72
- def close (self ): ...
73
- def is_same_host (self , url ) : ...
84
+ def close (self ) -> None : ...
85
+ def is_same_host (self , url : str ) -> bool : ...
74
86
def urlopen (
75
87
self ,
76
88
method ,
@@ -87,35 +99,33 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
87
99
): ...
88
100
89
101
class HTTPSConnectionPool (HTTPConnectionPool ):
90
- scheme : Any
91
- ConnectionCls : Any
92
- key_file : Any
93
- cert_file : Any
94
- cert_reqs : Any
95
- ca_certs : Any
96
- ssl_version : Any
97
- assert_hostname : Any
98
- assert_fingerprint : Any
102
+ key_file : str | None
103
+ cert_file : str | None
104
+ cert_reqs : int | str | None
105
+ ca_certs : str | None
106
+ ssl_version : int | str | None
107
+ assert_hostname : str | Literal [False ] | None
108
+ assert_fingerprint : str | None
99
109
def __init__ (
100
110
self ,
101
- host ,
102
- port = ...,
103
- strict = ...,
104
- timeout = ...,
105
- maxsize = ...,
106
- block = ...,
107
- headers = ...,
108
- retries = ...,
109
- _proxy = ...,
110
- _proxy_headers = ...,
111
- key_file = ...,
112
- cert_file = ...,
113
- cert_reqs = ...,
114
- ca_certs = ...,
115
- ssl_version = ...,
116
- assert_hostname = ...,
117
- assert_fingerprint = ...,
111
+ host : str ,
112
+ port : int | None = ...,
113
+ strict : bool = ...,
114
+ timeout : _Timeout = ...,
115
+ maxsize : int = ...,
116
+ block : bool = ...,
117
+ headers : Mapping [ str , str ] | None = ...,
118
+ retries : _Retries | None = ...,
119
+ _proxy : Url | None = ...,
120
+ _proxy_headers : Mapping [ str , str ] | None = ...,
121
+ key_file : str | None = ...,
122
+ cert_file : str | None = ...,
123
+ cert_reqs : int | str | None = ...,
124
+ ca_certs : str | None = ...,
125
+ ssl_version : int | str | None = ...,
126
+ assert_hostname : str | Literal [ False ] | None = ...,
127
+ assert_fingerprint : str | None = ...,
118
128
** conn_kw ,
119
129
) -> None : ...
120
130
121
- def connection_from_url (url , ** kw ): ...
131
+ def connection_from_url (url : str , ** kw ) -> HTTPConnectionPool : ...
0 commit comments