From d840609ecb974a2348c7c8f29c1d88003a1554d1 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 11 Sep 2025 18:38:59 +0200 Subject: [PATCH] fix: Fix annotation value comparison --- papis_extract/annotation.py | 8 ++++++-- tests/test_annotation.py | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/papis_extract/annotation.py b/papis_extract/annotation.py index 97bd950..d3dadb9 100644 --- a/papis_extract/annotation.py +++ b/papis_extract/annotation.py @@ -1,5 +1,4 @@ import math -from dataclasses import dataclass from typing import Any, cast import chevron @@ -21,7 +20,6 @@ COLORS: dict[str, tuple[float, float, float]] = { } -@dataclass class Annotation: """A PDF annotation object. @@ -140,3 +138,9 @@ class Annotation: ) return cast("dict[str, str]", rawvalue) + + def __str__(self) -> str: + return f"Annotation({self.type}: '{self.file}', color: {self.color}, tag: '{self.tag}', page: {self.page}, content: '{self.content}', note: '{self.note}', minimum_similarity_color: {self.minimum_similarity_color})" + + def __repr__(self) -> str: + return f"Annotation(type={self.type}, file='{self.file}', color={self.color}, tag='{self.tag}', page={self.page}, content='{self.content}', note='{self.note}', minimum_similarity_color={self.minimum_similarity_color})" diff --git a/tests/test_annotation.py b/tests/test_annotation.py index ceb0c0e..6d177a5 100644 --- a/tests/test_annotation.py +++ b/tests/test_annotation.py @@ -4,6 +4,12 @@ from papis.document import Document from papis_extract.annotation import Annotation +def test_value_comparison_works(): + sut = Annotation("myfile", content="Here be content!", note="and a note") + other = Annotation("myfile", content="Here be different content!", note="but still a note") + assert sut != other + + @pytest.mark.parametrize( "fmt_string,expected", [