Skip to content

Commit

Permalink
Add hash presentation support of CodeSnipped (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimitrov authored Feb 13, 2025
1 parent fa5bbc4 commit fcc1840
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/codegate/extract_snippets/message_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ def fill_file_extension(self) -> Self:
self.file_extension = Path(self.filepath).suffix
return self

def __hash__(self):
# Create a hashable representation using immutable fields
return hash(
(self.code, self.language, self.filepath, self.file_extension, tuple(self.libraries))
)

def __eq__(self, other):
if not isinstance(other, CodeSnippet):
return False
return (
self.code == other.code
and self.language == other.language
and self.filepath == other.filepath
and self.file_extension == other.file_extension
and self.libraries == other.libraries
)


class CodeSnippetExtractor(ABC):

Expand Down

0 comments on commit fcc1840

Please sign in to comment.