summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-01-17 09:04:51 +0100
committerMartin Fischer <martin@push-f.com>2022-01-17 11:42:48 +0100
commitdef62c3a47384b6672cb584cd586ea104b86754f (patch)
tree3c250dbc0f50ddcd82ba336afd638c362bc9df21
parent6d43cf7952cb22dbf8c7d1851eeee1931f8604c3 (diff)
[typing] add type hints for dictionaries
-rw-r--r--searx/network/client.py4
-rw-r--r--searx/network/network.py3
-rw-r--r--searx/search/processors/__init__.py3
-rw-r--r--searx/search/processors/abstract.py5
4 files changed, 10 insertions, 5 deletions
diff --git a/searx/network/client.py b/searx/network/client.py
index 6858ac05..11086dd3 100644
--- a/searx/network/client.py
+++ b/searx/network/client.py
@@ -4,7 +4,9 @@
import asyncio
import logging
+from ssl import SSLContext
import threading
+from typing import Any, Dict
import httpx
from httpx_socks import AsyncProxyTransport
@@ -23,7 +25,7 @@ else:
logger = logger.getChild('searx.network.client')
LOOP = None
-SSLCONTEXTS = {}
+SSLCONTEXTS: Dict[Any, SSLContext] = {}
TRANSPORT_KWARGS = {
'trust_env': False,
}
diff --git a/searx/network/network.py b/searx/network/network.py
index 43140b44..c9af9764 100644
--- a/searx/network/network.py
+++ b/searx/network/network.py
@@ -7,6 +7,7 @@ import atexit
import asyncio
import ipaddress
from itertools import cycle
+from typing import Dict
import httpx
@@ -16,7 +17,7 @@ from .client import new_client, get_loop, AsyncHTTPTransportNoHttp
logger = logger.getChild('network')
DEFAULT_NAME = '__DEFAULT__'
-NETWORKS = {}
+NETWORKS: Dict[str, 'Network'] = {}
# requests compatibility when reading proxy settings from settings.yml
PROXY_PATTERN_MAPPING = {
'http': 'http://',
diff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.py
index 966b990e..4e85527b 100644
--- a/searx/search/processors/__init__.py
+++ b/searx/search/processors/__init__.py
@@ -15,6 +15,7 @@ __all__ = [
]
import threading
+from typing import Dict
from searx import logger
from searx import engines
@@ -26,7 +27,7 @@ from .online_currency import OnlineCurrencyProcessor
from .abstract import EngineProcessor
logger = logger.getChild('search.processors')
-PROCESSORS = {}
+PROCESSORS: Dict[str, EngineProcessor] = {}
"""Cache request processores, stored by *engine-name* (:py:func:`initialize`)"""
diff --git a/searx/search/processors/abstract.py b/searx/search/processors/abstract.py
index 732b55d5..b7703496 100644
--- a/searx/search/processors/abstract.py
+++ b/searx/search/processors/abstract.py
@@ -8,6 +8,7 @@
import threading
from abc import abstractmethod, ABC
from timeit import default_timer
+from typing import Dict, Union
from searx import settings, logger
from searx.engines import engines
@@ -17,7 +18,7 @@ from searx.exceptions import SearxEngineAccessDeniedException, SearxEngineRespon
from searx.utils import get_engine_from_settings
logger = logger.getChild('searx.search.processor')
-SUSPENDED_STATUS = {}
+SUSPENDED_STATUS: Dict[Union[int, str], 'SuspendedStatus'] = {}
class SuspendedStatus:
@@ -61,7 +62,7 @@ class EngineProcessor(ABC):
__slots__ = 'engine', 'engine_name', 'lock', 'suspended_status', 'logger'
- def __init__(self, engine, engine_name):
+ def __init__(self, engine, engine_name: str):
self.engine = engine
self.engine_name = engine_name
self.logger = engines[engine_name].logger