File tree Expand file tree Collapse file tree 5 files changed +21
-15
lines changed Expand file tree Collapse file tree 5 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 2727if TYPE_CHECKING :
2828 from hashlib import _Hash
2929
30- from pip ._vendor .requests .models import Request , Response
30+ from pip ._vendor .requests .models import PreparedRequest , Request , Response
3131
3232 from pip ._internal .metadata import BaseDistribution
3333 from pip ._internal .network .download import _FileDownload
@@ -314,7 +314,7 @@ def __init__(
314314 self ,
315315 error_msg : str ,
316316 response : Response | None = None ,
317- request : Request | None = None ,
317+ request : Request | PreparedRequest | None = None ,
318318 ) -> None :
319319 """
320320 Initialize NetworkConnectionError with `request` and `response`
Original file line number Diff line number Diff line change 66import pathlib
77import sys
88import sysconfig
9- from typing import Any
109
1110from pip ._internal .models .scheme import SCHEME_KEYS , Scheme
1211from pip ._internal .utils .compat import WINDOWS
@@ -134,7 +133,7 @@ def _looks_like_red_hat_scheme() -> bool:
134133 from distutils .command .install import install
135134 from distutils .dist import Distribution
136135
137- cmd : Any = install (Distribution ())
136+ cmd = install (Distribution ())
138137 cmd .finalize_options ()
139138 return (
140139 cmd .exec_prefix == f"{ os .path .normpath (sys .exec_prefix )} /local"
Original file line number Diff line number Diff line change 44import os
55import sys
66import sysconfig
7+ from typing import Callable
78
89from pip ._internal .exceptions import InvalidSchemeCombination , UserInstallationInvalid
910from pip ._internal .models .scheme import SCHEME_KEYS , Scheme
2425
2526_AVAILABLE_SCHEMES = set (sysconfig .get_scheme_names ())
2627
27- _PREFERRED_SCHEME_API = getattr (sysconfig , "get_preferred_scheme" , None )
28+ _PREFERRED_SCHEME_API : Callable [[str ], str ] | None = getattr (
29+ sysconfig , "get_preferred_scheme" , None
30+ )
2831
2932
3033def _should_use_osx_framework_prefix () -> bool :
Original file line number Diff line number Diff line change 99import os .path
1010import sys
1111from dataclasses import dataclass
12- from typing import Any , Callable
12+ from typing import Callable
1313
1414from pip ._vendor .packaging .version import Version
1515from pip ._vendor .packaging .version import parse as parse_version
@@ -61,7 +61,7 @@ def _convert_date(isodate: str) -> datetime.datetime:
6161
6262class SelfCheckState :
6363 def __init__ (self , cache_dir : str ) -> None :
64- self ._state : dict [str , Any ] = {}
64+ self ._state : dict [str , str ] = {}
6565 self ._statefile_path = None
6666
6767 # Try to load the existing state
Original file line number Diff line number Diff line change @@ -541,14 +541,18 @@ def __repr__(self) -> str:
541541 def __str__ (self ) -> str :
542542 return self .redacted
543543
544- # This is useful for testing.
545- def __eq__ (self , other : Any ) -> bool :
546- if type (self ) is not type (other ):
547- return False
548-
549- # The string being used for redaction doesn't also have to match,
550- # just the raw, original string.
551- return self .secret == other .secret
544+ def __eq__ (self , other : object ) -> bool :
545+ # Equality is particularly useful for testing.
546+ if type (self ) is type (other ):
547+ # The string being used for redaction doesn't also have to match,
548+ # just the raw, original string.
549+ return self .secret == cast (HiddenText , other ).secret
550+ return NotImplemented
551+
552+ # Disable hashing, since we have a custom __eq__ and don't need hash-ability
553+ # (yet). The only required property of hashing is that objects which compare
554+ # equal have the same hash value.
555+ __hash__ = None # type: ignore[assignment]
552556
553557
554558def hide_value (value : str ) -> HiddenText :
You can’t perform that action at this time.
0 commit comments