diff --git a/mypy/types.py b/mypy/types.py index 207e87984bed..a945ce044136 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -3242,7 +3242,6 @@ def __init__( super().__init__(line, column) self.value = value self.fallback = fallback - self._hash = -1 # Cached hash value # NOTE: Enum types are always truthy by default, but this can be changed # in subclasses, so we need to get the truthyness from the Enum @@ -3272,13 +3271,11 @@ def accept(self, visitor: TypeVisitor[T]) -> T: return visitor.visit_literal_type(self) def __hash__(self) -> int: - if self._hash == -1: - self._hash = hash((self.value, self.fallback)) - return self._hash + return hash(self.value) def __eq__(self, other: object) -> bool: if isinstance(other, LiteralType): - return self.fallback == other.fallback and self.value == other.value + return self.value == other.value and self.fallback == other.fallback else: return NotImplemented