summaryrefslogtreecommitdiff
path: root/searx/search/models.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2025-09-11 19:10:27 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-09-18 19:40:03 +0200
commit8f8343dc0d78bb57215afc3e99fd9000fce6e0cf (patch)
tree7c0aa8587ed4bc47e403b4148a308191e2d21c55 /searx/search/models.py
parent23257bddce864cfc44d64324dee36b32b1cf5248 (diff)
[mod] addition of various type hints / engine processors
Continuation of #5147 .. typification of the engine processors. BTW: - removed obsolete engine property https_support - fixed & improved currency_convert - engine instances can now implement a engine.setup method [#5147] https://github.com/searxng/searxng/pull/5147 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/search/models.py')
-rw-r--r--searx/search/models.py33
1 files changed, 10 insertions, 23 deletions
diff --git a/searx/search/models.py b/searx/search/models.py
index 62424390f..6d14a9657 100644
--- a/searx/search/models.py
+++ b/searx/search/models.py
@@ -24,42 +24,29 @@ class EngineRef:
return hash((self.name, self.category))
+@typing.final
class SearchQuery:
"""container for all the search parameters (query, language, etc...)"""
- __slots__ = (
- 'query',
- 'engineref_list',
- 'lang',
- 'locale',
- 'safesearch',
- 'pageno',
- 'time_range',
- 'timeout_limit',
- 'external_bang',
- 'engine_data',
- 'redirect_to_first_result',
- )
-
def __init__(
self,
query: str,
- engineref_list: typing.List[EngineRef],
+ engineref_list: list[EngineRef],
lang: str = 'all',
- safesearch: int = 0,
+ safesearch: typing.Literal[0, 1, 2] = 0,
pageno: int = 1,
- time_range: typing.Optional[str] = None,
- timeout_limit: typing.Optional[float] = None,
- external_bang: typing.Optional[str] = None,
- engine_data: typing.Optional[typing.Dict[str, str]] = None,
- redirect_to_first_result: typing.Optional[bool] = None,
+ time_range: typing.Literal["day", "week", "month", "year"] | None = None,
+ timeout_limit: float | None = None,
+ external_bang: str | None = None,
+ engine_data: dict[str, dict[str, str]] | None = None,
+ redirect_to_first_result: bool | None = None,
): # pylint:disable=too-many-arguments
self.query = query
self.engineref_list = engineref_list
self.lang = lang
- self.safesearch = safesearch
+ self.safesearch: typing.Literal[0, 1, 2] = safesearch
self.pageno = pageno
- self.time_range = time_range
+ self.time_range: typing.Literal["day", "week", "month", "year"] | None = time_range
self.timeout_limit = timeout_limit
self.external_bang = external_bang
self.engine_data = engine_data or {}