fix: Fix annotation value comparison

This commit is contained in:
Marty Oehme 2025-09-11 18:38:59 +02:00
parent 3344147f1f
commit d840609ecb
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 12 additions and 2 deletions

View file

@ -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})"

View file

@ -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",
[