Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
if TYPE_CHECKING:
from hashlib import _Hash

from pip._vendor.requests.models import Request, Response
from pip._vendor.requests.models import PreparedRequest, Request, Response

from pip._internal.metadata import BaseDistribution
from pip._internal.network.download import _FileDownload
Expand Down Expand Up @@ -314,7 +314,7 @@ def __init__(
self,
error_msg: str,
response: Response | None = None,
request: Request | None = None,
request: Request | PreparedRequest | None = None,
) -> None:
"""
Initialize NetworkConnectionError with `request` and `response`
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pathlib
import sys
import sysconfig
from typing import Any

from pip._internal.models.scheme import SCHEME_KEYS, Scheme
from pip._internal.utils.compat import WINDOWS
Expand Down Expand Up @@ -134,7 +133,7 @@ def _looks_like_red_hat_scheme() -> bool:
from distutils.command.install import install
from distutils.dist import Distribution

cmd: Any = install(Distribution())
cmd = install(Distribution())
cmd.finalize_options()
return (
cmd.exec_prefix == f"{os.path.normpath(sys.exec_prefix)}/local"
Expand Down
5 changes: 4 additions & 1 deletion src/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import sysconfig
from typing import Callable

from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
from pip._internal.models.scheme import SCHEME_KEYS, Scheme
Expand All @@ -24,7 +25,9 @@

_AVAILABLE_SCHEMES = set(sysconfig.get_scheme_names())

_PREFERRED_SCHEME_API = getattr(sysconfig, "get_preferred_scheme", None)
_PREFERRED_SCHEME_API: Callable[[str], str] | None = getattr(
sysconfig, "get_preferred_scheme", None
)


def _should_use_osx_framework_prefix() -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/self_outdated_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os.path
import sys
from dataclasses import dataclass
from typing import Any, Callable
from typing import Callable

from pip._vendor.packaging.version import Version
from pip._vendor.packaging.version import parse as parse_version
Expand Down Expand Up @@ -61,7 +61,7 @@ def _convert_date(isodate: str) -> datetime.datetime:

class SelfCheckState:
def __init__(self, cache_dir: str) -> None:
self._state: dict[str, Any] = {}
self._state: dict[str, str] = {}
self._statefile_path = None

# Try to load the existing state
Expand Down
20 changes: 12 additions & 8 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,18 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return self.redacted

# This is useful for testing.
def __eq__(self, other: Any) -> bool:
if type(self) is not type(other):
return False

# The string being used for redaction doesn't also have to match,
# just the raw, original string.
return self.secret == other.secret
def __eq__(self, other: object) -> bool:
# Equality is particularly useful for testing.
if type(self) is type(other):
# The string being used for redaction doesn't also have to match,
# just the raw, original string.
return self.secret == cast(HiddenText, other).secret
return NotImplemented

# Disable hashing, since we have a custom __eq__ and don't need hash-ability
# (yet). The only required property of hashing is that objects which compare
# equal have the same hash value.
__hash__ = None # type: ignore[assignment]


def hide_value(value: str) -> HiddenText:
Expand Down