Skip to content

Commit fcc1840

Browse files
authored
Add hash presentation support of CodeSnipped (#1041)
1 parent fa5bbc4 commit fcc1840

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/codegate/extract_snippets/message_extractor.py

+17
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ def fill_file_extension(self) -> Self:
116116
self.file_extension = Path(self.filepath).suffix
117117
return self
118118

119+
def __hash__(self):
120+
# Create a hashable representation using immutable fields
121+
return hash(
122+
(self.code, self.language, self.filepath, self.file_extension, tuple(self.libraries))
123+
)
124+
125+
def __eq__(self, other):
126+
if not isinstance(other, CodeSnippet):
127+
return False
128+
return (
129+
self.code == other.code
130+
and self.language == other.language
131+
and self.filepath == other.filepath
132+
and self.file_extension == other.file_extension
133+
and self.libraries == other.libraries
134+
)
135+
119136

120137
class CodeSnippetExtractor(ABC):
121138

0 commit comments

Comments
 (0)