@@ -229,11 +229,11 @@ def send(
229
229
cert : bytes | str | tuple [bytes | str , bytes | str ] | None = None ,
230
230
proxies : Mapping [str , str ] | None = None ,
231
231
) -> Response :
232
+ assert request .url is not None
232
233
pathname = url_to_path (request .url )
233
234
234
235
resp = Response ()
235
236
resp .status_code = 200
236
- assert request .url is not None
237
237
resp .url = request .url
238
238
239
239
try :
@@ -250,13 +250,13 @@ def send(
250
250
resp .headers = CaseInsensitiveDict (
251
251
{
252
252
"Content-Type" : content_type ,
253
- "Content-Length" : stats .st_size ,
253
+ "Content-Length" : str ( stats .st_size ) ,
254
254
"Last-Modified" : modified ,
255
255
}
256
256
)
257
257
258
258
resp .raw = open (pathname , "rb" )
259
- resp .close = resp .raw .close
259
+ resp .close = resp .raw .close # type: ignore[method-assign]
260
260
261
261
return resp
262
262
@@ -336,6 +336,9 @@ def cert_verify(
336
336
337
337
338
338
class PipSession (requests .Session ):
339
+ # Let the type checker know that we are using a custom auth handler.
340
+ auth : MultiDomainBasicAuth
341
+
339
342
timeout : int | None = None
340
343
341
344
def __init__ (
@@ -363,11 +366,11 @@ def __init__(
363
366
self .headers ["User-Agent" ] = user_agent ()
364
367
365
368
# Attach our Authentication handler to the session
366
- self .auth = MultiDomainBasicAuth (index_urls = index_urls ) # type: ignore[assignment]
369
+ self .auth = MultiDomainBasicAuth (index_urls = index_urls )
367
370
368
371
# Create our urllib3.Retry instance which will allow us to customize
369
372
# how we handle retries.
370
- retries = urllib3 .Retry (
373
+ retry = urllib3 .Retry (
371
374
# Set the total number of retries that a particular request can
372
375
# have.
373
376
total = retries ,
@@ -382,14 +385,14 @@ def __init__(
382
385
# Add a small amount of back off between failed requests in
383
386
# order to prevent hammering the service.
384
387
backoff_factor = 0.25 ,
385
- ) # type: ignore
388
+ )
386
389
387
390
# Our Insecure HTTPAdapter disables HTTPS validation. It does not
388
391
# support caching so we'll use it for all http:// URLs.
389
392
# If caching is disabled, we will also use it for
390
393
# https:// hosts that we've marked as ignoring
391
394
# TLS errors for (trusted-hosts).
392
- insecure_adapter = InsecureHTTPAdapter (max_retries = retries )
395
+ insecure_adapter = InsecureHTTPAdapter (max_retries = retry )
393
396
394
397
# We want to _only_ cache responses on securely fetched origins or when
395
398
# the host is specified as trusted. We do this because
@@ -401,19 +404,19 @@ def __init__(
401
404
HTTPAdapter ,
402
405
CacheControlAdapter (
403
406
cache = SafeFileCache (cache ),
404
- max_retries = retries ,
407
+ max_retries = retry ,
405
408
ssl_context = ssl_context ,
406
409
),
407
410
)
408
411
self ._trusted_host_adapter = cast (
409
412
HTTPAdapter ,
410
413
InsecureCacheControlAdapter (
411
414
cache = SafeFileCache (cache ),
412
- max_retries = retries ,
415
+ max_retries = retry ,
413
416
),
414
417
)
415
418
else :
416
- secure_adapter = HTTPAdapter (max_retries = retries , ssl_context = ssl_context )
419
+ secure_adapter = HTTPAdapter (max_retries = retry , ssl_context = ssl_context )
417
420
self ._trusted_host_adapter = insecure_adapter
418
421
419
422
self .mount ("https://" , secure_adapter )
@@ -537,7 +540,9 @@ def is_secure_origin(self, location: Link) -> bool:
537
540
538
541
return False
539
542
540
- def request (self , method : str , url : str , * args : Any , ** kwargs : Any ) -> Response :
543
+ def request ( # type: ignore[override]
544
+ self , method : str , url : str , * args : Any , ** kwargs : Any
545
+ ) -> Response :
541
546
# Allow setting a default timeout on a session
542
547
kwargs .setdefault ("timeout" , self .timeout )
543
548
# Allow setting a default proxies on a session
0 commit comments