Skip to content

Commit a9daab6

Browse files
committed
implement the __hash__ method on the underlying class for compliance with best practices
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
1 parent a374384 commit a9daab6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/response_codes/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ def __ge__(cls, other: int) -> bool:
137137
return cls.status_code >= other
138138
return NotImplemented
139139

140+
def __hash__(cls) -> int:
141+
"""Return hash based on the status code.
142+
143+
Returns:
144+
int: Hash value based on the status code
145+
"""
146+
return hash(cls.status_code)
147+
140148

141149
class HTTPStatus(Exception, metaclass=HTTPStatusMeta):
142150
"""Base class for HTTP status code exceptions.

0 commit comments

Comments
 (0)