[fix] minor type hint issues (#5459)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2025-11-20 18:35:43 +01:00 committed by GitHub
parent 21a4622f23
commit b299386d3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ import httpx
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
import searx.preferences import searx.preferences
import searx.results import searx.results
from searx.search.processors import ParamTypes from searx.search.processors import OnlineParamTypes
class SXNG_Request(flask.Request): class SXNG_Request(flask.Request):
@ -83,4 +83,4 @@ class SXNG_Response(httpx.Response):
""" """
ok: bool ok: bool
search_params: "ParamTypes" search_params: "OnlineParamTypes"

View File

@ -35,7 +35,7 @@ class HTTPParams(t.TypedDict):
headers: dict[str, str] headers: dict[str, str]
"""HTTP header information.""" """HTTP header information."""
data: dict[str, str] data: dict[str, str | int | dict[str, str | int]]
"""Sending `form encoded data`_. """Sending `form encoded data`_.
.. _form encoded data: .. _form encoded data:
@ -56,7 +56,7 @@ class HTTPParams(t.TypedDict):
https://www.python-httpx.org/quickstart/#sending-json-encoded-data https://www.python-httpx.org/quickstart/#sending-json-encoded-data
""" """
url: str url: str | None
"""Requested url.""" """Requested url."""
cookies: dict[str, str] cookies: dict[str, str]
@ -200,7 +200,7 @@ class OnlineProcessor(EngineProcessor):
request_args["content"] = params["content"] request_args["content"] = params["content"]
# send the request # send the request
response = req(params["url"], **request_args) response = req(params["url"], **request_args) # pyright: ignore[reportArgumentType]
# check soft limit of the redirect count # check soft limit of the redirect count
if len(response.history) > soft_max_redirects: if len(response.history) > soft_max_redirects:

View File

@ -741,7 +741,7 @@ def detect_language(text: str, threshold: float = 0.3, only_search_languages: bo
return None return None
def js_variable_to_python(js_variable: str) -> str: def js_variable_to_python(js_variable: str) -> t.Any:
"""Convert a javascript variable into JSON and then load the value """Convert a javascript variable into JSON and then load the value
It does not deal with all cases, but it is good enough for now. It does not deal with all cases, but it is good enough for now.
@ -808,7 +808,7 @@ def js_variable_to_python(js_variable: str) -> str:
# replace the surogate character by colon # replace the surogate character by colon
s = s.replace(chr(1), ':') s = s.replace(chr(1), ':')
# load the JSON and return the result # load the JSON and return the result
return json.loads(s) # pyright: ignore[reportAny] return json.loads(s)
def parse_duration_string(duration_str: str) -> timedelta | None: def parse_duration_string(duration_str: str) -> timedelta | None: