@@ -229,11 +229,11 @@ def send(
229229 cert : bytes | str | tuple [bytes | str , bytes | str ] | None = None ,
230230 proxies : Mapping [str , str ] | None = None ,
231231 ) -> Response :
232+ assert request .url is not None
232233 pathname = url_to_path (request .url )
233234
234235 resp = Response ()
235236 resp .status_code = 200
236- assert request .url is not None
237237 resp .url = request .url
238238
239239 try :
@@ -250,13 +250,13 @@ def send(
250250 resp .headers = CaseInsensitiveDict (
251251 {
252252 "Content-Type" : content_type ,
253- "Content-Length" : stats .st_size ,
253+ "Content-Length" : str ( stats .st_size ) ,
254254 "Last-Modified" : modified ,
255255 }
256256 )
257257
258258 resp .raw = open (pathname , "rb" )
259- resp .close = resp .raw .close
259+ resp .close = resp .raw .close # type: ignore[method-assign]
260260
261261 return resp
262262
@@ -336,6 +336,9 @@ def cert_verify(
336336
337337
338338class PipSession (requests .Session ):
339+ # Let the type checker know that we are using a custom auth handler.
340+ auth : MultiDomainBasicAuth
341+
339342 timeout : int | None = None
340343
341344 def __init__ (
@@ -363,11 +366,11 @@ def __init__(
363366 self .headers ["User-Agent" ] = user_agent ()
364367
365368 # 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 )
367370
368371 # Create our urllib3.Retry instance which will allow us to customize
369372 # how we handle retries.
370- retries = urllib3 .Retry (
373+ retry = urllib3 .Retry (
371374 # Set the total number of retries that a particular request can
372375 # have.
373376 total = retries ,
@@ -382,14 +385,14 @@ def __init__(
382385 # Add a small amount of back off between failed requests in
383386 # order to prevent hammering the service.
384387 backoff_factor = 0.25 ,
385- ) # type: ignore
388+ )
386389
387390 # Our Insecure HTTPAdapter disables HTTPS validation. It does not
388391 # support caching so we'll use it for all http:// URLs.
389392 # If caching is disabled, we will also use it for
390393 # https:// hosts that we've marked as ignoring
391394 # TLS errors for (trusted-hosts).
392- insecure_adapter = InsecureHTTPAdapter (max_retries = retries )
395+ insecure_adapter = InsecureHTTPAdapter (max_retries = retry )
393396
394397 # We want to _only_ cache responses on securely fetched origins or when
395398 # the host is specified as trusted. We do this because
@@ -401,19 +404,19 @@ def __init__(
401404 HTTPAdapter ,
402405 CacheControlAdapter (
403406 cache = SafeFileCache (cache ),
404- max_retries = retries ,
407+ max_retries = retry ,
405408 ssl_context = ssl_context ,
406409 ),
407410 )
408411 self ._trusted_host_adapter = cast (
409412 HTTPAdapter ,
410413 InsecureCacheControlAdapter (
411414 cache = SafeFileCache (cache ),
412- max_retries = retries ,
415+ max_retries = retry ,
413416 ),
414417 )
415418 else :
416- secure_adapter = HTTPAdapter (max_retries = retries , ssl_context = ssl_context )
419+ secure_adapter = HTTPAdapter (max_retries = retry , ssl_context = ssl_context )
417420 self ._trusted_host_adapter = insecure_adapter
418421
419422 self .mount ("https://" , secure_adapter )
@@ -537,7 +540,9 @@ def is_secure_origin(self, location: Link) -> bool:
537540
538541 return False
539542
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 :
541546 # Allow setting a default timeout on a session
542547 kwargs .setdefault ("timeout" , self .timeout )
543548 # Allow setting a default proxies on a session
0 commit comments