From e57ebb0aa549d9bbf634e906dcfa6372d3614f4a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 16 Sep 2026 11:03:15 +0200 Subject: [PATCH] [refactor] engine processors: add type for time range and safesearch in OnlineParams --- searx/engines/kagi.py | 2 +- searx/search/processors/abstract.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/searx/engines/kagi.py b/searx/engines/kagi.py index 7189b5eb3..205e2c44a 100644 --- a/searx/engines/kagi.py +++ b/searx/engines/kagi.py @@ -47,6 +47,7 @@ from datetime import datetime, timedelta import typing as t +from searx.search.processors.abstract import TimeRangeType from searx.extended_types import SXNG_Response from searx.result_types import EngineResults from searx.utils import html_to_text, parse_duration_string @@ -54,7 +55,6 @@ from searx.utils import html_to_text, parse_duration_string if t.TYPE_CHECKING: from searx.search.processors import OnlineParams -TimeRangeType = t.Literal["day", "week", "month", "year"] about = { "website": "https://kagi.com", "wikidata_id": "Q26000117", diff --git a/searx/search/processors/abstract.py b/searx/search/processors/abstract.py index 8c8bc5f85..921587f0a 100644 --- a/searx/search/processors/abstract.py +++ b/searx/search/processors/abstract.py @@ -29,6 +29,10 @@ logger = logger.getChild("searx.search.processor") SUSPENDED_STATUS: dict[int | str, "SuspendedStatus"] = {} +TimeRangeType = t.Literal["day", "week", "month", "year"] +SafesearchType = t.Literal[0, 1, 2] + + class RequestParams(t.TypedDict): """Basic quantity of the Request parameters of all engine types.""" @@ -51,10 +55,10 @@ class RequestParams(t.TypedDict): pageno: int """Current page number, where the first page is ``1``.""" - safesearch: t.Literal[0, 1, 2] + safesearch: SafesearchType """Safe-Search filter (0:normal, 1:moderate, 2:strict).""" - time_range: t.Literal["day", "week", "month", "year"] | None + time_range: TimeRangeType | None """Time-range filter.""" engine_data: dict[str, str]