From 37bbd2cba219d634c6244c9a255633b8d4ac53c9 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 1 Dec 2023 16:50:42 +0100 Subject: [PATCH] fix mypy --- mypy.ini | 2 +- src/collective/elastic/ingest/celery.py | 4 ++-- src/collective/elastic/ingest/{ingest.py => ingestion.py} | 2 +- src/collective/elastic/ingest/preprocessing.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/collective/elastic/ingest/{ingest.py => ingestion.py} (98%) diff --git a/mypy.ini b/mypy.ini index f21d8ff..9771aac 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,2 @@ [mypy] -mypy_path=./src +packages=collective.elastic.ingest diff --git a/src/collective/elastic/ingest/celery.py b/src/collective/elastic/ingest/celery.py index 82bced1..02acb88 100644 --- a/src/collective/elastic/ingest/celery.py +++ b/src/collective/elastic/ingest/celery.py @@ -1,4 +1,4 @@ -from .ingest import ingest +from .ingestion import process_ingest from .logging import logger from .plone import fetch_content from .plone import fetch_schema @@ -52,7 +52,7 @@ def index(path, timestamp, index_name): logger.exception(msg) return msg try: - ingest(content, schema, index_name) + process_ingest(content, schema, index_name) except Exception: # xxx: retry handling! msg = "Error while writing data to ElasticSearch" diff --git a/src/collective/elastic/ingest/ingest.py b/src/collective/elastic/ingest/ingestion.py similarity index 98% rename from src/collective/elastic/ingest/ingest.py rename to src/collective/elastic/ingest/ingestion.py index bbf3c33..a4da015 100644 --- a/src/collective/elastic/ingest/ingest.py +++ b/src/collective/elastic/ingest/ingestion.py @@ -75,7 +75,7 @@ def setup_ingest_pipelines(full_schema, index_name): client.ingest.delete_pipeline(pipeline_name) -def ingest(content, full_schema, index_name): +def process_ingest(content, full_schema, index_name): """Process content and schema. This brings it together: Preprocess, create a mapping (and index/pipelines if not exists yet), diff --git a/src/collective/elastic/ingest/preprocessing.py b/src/collective/elastic/ingest/preprocessing.py index 41495ec..f6eb8c7 100644 --- a/src/collective/elastic/ingest/preprocessing.py +++ b/src/collective/elastic/ingest/preprocessing.py @@ -156,7 +156,7 @@ def action_empty_removal(content, full_schema, key): ACTION_FUNCTIONS["remove_empty"] = action_empty_removal -def action_strip_vocabulary_term_titles(content, full_schema): +def action_strip_vocabulary_term_titles(content, full_schema, config): """If field with vocabulary: Convert field value to token or list of tokens.""" for fieldname, field in content.items(): if isinstance(field, dict) and set(field.keys()) == {"title", "token"}: @@ -173,7 +173,7 @@ def action_strip_vocabulary_term_titles(content, full_schema): ACTION_FUNCTIONS["strip_vocabulary_term_titles"] = action_strip_vocabulary_term_titles -def action_enrich_with_section(content, fullschema): +def action_enrich_with_section(content, fullschema, config): """Add section to content. TODO: make this take the site root into account and remove this step (see below)