From 9c80281220474329c5599e39a7b5ebc00cf4d0b5 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 30 Nov 2024 21:22:45 +0100 Subject: [PATCH 1/3] fix: Respect minimum color similarity option Previously we would always assign a minimum color similarity of 1.0, regardless of the option set. Now we set a minimum similarity according to the option set in the configuration, otherwise the default set for that option and fall back to a simple default value declared at the top of the file. --- papis_extract/annotation.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/papis_extract/annotation.py b/papis_extract/annotation.py index 54b216d..8fd63ac 100644 --- a/papis_extract/annotation.py +++ b/papis_extract/annotation.py @@ -6,8 +6,7 @@ import chevron import papis.config from papis.document import Document -TEXT_SIMILARITY_MINIMUM = 0.75 -COLOR_SIMILARITY_MINIMUM = 0.833 +COLOR_SIMILARITY_MINIMUM_FALLBACK = 0.833 COLORS: dict[str, tuple[float, float, float]] = { "blue": (0, 0, 1), @@ -38,14 +37,17 @@ class Annotation: page: int = 0, tag: str = "", type: str = "Highlight", - minimum_similarity_color: float = 1.0, + minimum_similarity_color: float | None = None, ) -> None: - self.minimum_similarity_color = minimum_similarity_color self.file = file self._color = color self.content = content self.note = note self.page = page + self.minimum_similarity_color = minimum_similarity_color or ( + papis.config.getfloat("minimum_similarity_color", "plugins.extract") + or COLOR_SIMILARITY_MINIMUM_FALLBACK + ) self.tag = tag or self._tag_from_colorname(self.colorname or "") self.type = type @@ -85,9 +87,6 @@ class Annotation: """ annot_colors = self.color or (0.0, 0.0, 0.0) nearest = None - minimum_similarity = ( - papis.config.getfloat("minimum_similarity_color", "plugins.extract") or 1.0 - ) minimum_similarity = self.minimum_similarity_color for name, values in COLORS.items(): similarity_ratio = self._color_similarity_ratio(values, annot_colors) From ddaa75f44b9c598894e01074ebc0cd82df223e1c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 30 Nov 2024 21:45:59 +0100 Subject: [PATCH 2/3] chore: Change woodpecker ci to use uv --- .woodpecker/static_analysis.yml | 6 +++--- .woodpecker/test.yml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.woodpecker/static_analysis.yml b/.woodpecker/static_analysis.yml index b817624..5244d3a 100644 --- a/.woodpecker/static_analysis.yml +++ b/.woodpecker/static_analysis.yml @@ -3,7 +3,7 @@ steps: image: nikolaik/python-nodejs commands: - npm install --global pyright - - poetry install - - python --version && poetry --version && pyright --version + - uv sync + - python --version && uv version && pyright --version - echo "------------- running pyright typecheck -------------" - - poetry run pyright + - uv run pyright diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml index 0dc8073..5ae9b1d 100644 --- a/.woodpecker/test.yml +++ b/.woodpecker/test.yml @@ -3,9 +3,9 @@ when: steps: pytest: - image: ghcr.io/withlogicco/poetry:1.5.1 + image: nikolaik/python-nodejs commands: - - poetry install - - python --version && poetry --version + - uv sync + - python --version && uv version - echo "------------- running pytest -------------" - - poetry run pytest + - uv run pytest From 682b7577de45e640e9ec01d77132d80912cc4765 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 30 Nov 2024 21:47:38 +0100 Subject: [PATCH 3/3] chore: Remove redundant cast --- papis_extract/extractors/pdf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/papis_extract/extractors/pdf.py b/papis_extract/extractors/pdf.py index 906fdec..8caaf5c 100644 --- a/papis_extract/extractors/pdf.py +++ b/papis_extract/extractors/pdf.py @@ -35,7 +35,6 @@ class PdfExtractor: for ( page ) in doc: # pyright: ignore [reportUnknownVariableType] - missing stub - page = cast(mu.Page, page) annot: mu.Annot for annot in page.annots(): quote, note = self._retrieve_annotation_content(page, annot)