Skip to content

Commit b572e96

Browse files
committed
Disable hashing on HiddenText, since we have a custom __eq__.
1 parent 72554d7 commit b572e96

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pip/_internal/utils/misc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,17 @@ def __str__(self) -> str:
543543

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

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]
556+
553557

554558
def hide_value(value: str) -> HiddenText:
555559
return HiddenText(value, redacted="****")

0 commit comments

Comments
 (0)