Skip to content

Commit 02c8b5c

Browse files
committed
Fix all "Incompatible types in assignment"
1 parent 9931fb5 commit 02c8b5c

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/pip/_internal/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from hashlib import _Hash
2929

3030
# Vendored libraries with type stubs
31-
from requests.models import Request, Response
31+
from requests.models import PreparedRequest, Request, Response
3232

3333
from pip._internal.metadata import BaseDistribution
3434
from pip._internal.network.download import _FileDownload
@@ -298,7 +298,7 @@ def __init__(
298298
self,
299299
error_msg: str,
300300
response: Response | None = None,
301-
request: Request | None = None,
301+
request: Request | PreparedRequest | None = None,
302302
) -> None:
303303
"""
304304
Initialize NetworkConnectionError with `request` and `response`

src/pip/_internal/locations/_distutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import os
2121
import sys
2222
from distutils.command.install import SCHEME_KEYS # type: ignore
23-
from typing import TYPE_CHECKING
23+
from typing import TYPE_CHECKING, cast
2424

2525
from pip._internal.models.scheme import Scheme
2626
from pip._internal.utils.compat import WINDOWS
@@ -77,7 +77,7 @@ def distutils_scheme(
7777
obj: DistutilsCommand | None = None
7878
obj = d.get_command_obj("install", create=True)
7979
assert obj is not None
80-
i: distutils_install_command = obj
80+
i = cast(distutils_install_command, obj)
8181
# NOTE: setting user or home has the side-effect of creating the home dir
8282
# or user base for installations during finalize_options()
8383
# ideally, we'd prefer a scheme class that has no side-effects.

src/pip/_internal/network/session.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Any,
2525
Optional,
2626
Union,
27+
cast,
2728
)
2829

2930
from pip import __version__
@@ -223,15 +224,16 @@ def send(
223224
self,
224225
request: PreparedRequest,
225226
stream: bool = False,
226-
timeout: float | tuple[float, float] | None = None,
227+
timeout: float | tuple[float, float] | tuple[float, None] | None = None,
227228
verify: bool | str = True,
228-
cert: str | tuple[str, str] | None = None,
229+
cert: bytes | str | tuple[bytes | str, bytes | str] | None = None,
229230
proxies: Mapping[str, str] | None = None,
230231
) -> Response:
231232
pathname = url_to_path(request.url)
232233

233234
resp = Response()
234235
resp.status_code = 200
236+
assert request.url is not None
235237
resp.url = request.url
236238

237239
try:
@@ -361,7 +363,7 @@ def __init__(
361363
self.headers["User-Agent"] = user_agent()
362364

363365
# Attach our Authentication handler to the session
364-
self.auth = MultiDomainBasicAuth(index_urls=index_urls)
366+
self.auth = MultiDomainBasicAuth(index_urls=index_urls) # type: ignore[assignment]
365367

366368
# Create our urllib3.Retry instance which will allow us to customize
367369
# how we handle retries.
@@ -395,14 +397,20 @@ def __init__(
395397
# origin, and we don't want someone to be able to poison the cache and
396398
# require manual eviction from the cache to fix it.
397399
if cache:
398-
secure_adapter = CacheControlAdapter(
399-
cache=SafeFileCache(cache),
400-
max_retries=retries,
401-
ssl_context=ssl_context,
400+
secure_adapter = cast(
401+
HTTPAdapter,
402+
CacheControlAdapter(
403+
cache=SafeFileCache(cache),
404+
max_retries=retries,
405+
ssl_context=ssl_context,
406+
),
402407
)
403-
self._trusted_host_adapter = InsecureCacheControlAdapter(
404-
cache=SafeFileCache(cache),
405-
max_retries=retries,
408+
self._trusted_host_adapter = cast(
409+
HTTPAdapter,
410+
InsecureCacheControlAdapter(
411+
cache=SafeFileCache(cache),
412+
max_retries=retries,
413+
),
406414
)
407415
else:
408416
secure_adapter = HTTPAdapter(max_retries=retries, ssl_context=ssl_context)

0 commit comments

Comments
 (0)