SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] issues reported by pylint v4.1.2 (#6827)
Markus Heiserbba4f64e8a05
diff --git a/searx/data/tracker_patterns.py b/searx/data/tracker_patterns.pyindex 9c61efb68..6f9c2db52 100644--- a/searx/data/tracker_patterns.py+++ b/searx/data/tracker_patterns.py@@ -93,7 +93,7 @@ class TrackerPatternsDB:continueif resp.status_code != 200:- log.warning(f"TRACKER_PATTERNS: ClearURL ignore HTTP {resp.status_code} {url}")+ log.warning("TRACKER_PATTERNS: ClearURL ignore HTTP %s %s", resp.status_code, url)continuebreakdiff --git a/searx/engines/__init__.py b/searx/engines/__init__.pyindex cb5e3a7d2..03979bb38 100644--- a/searx/engines/__init__.py+++ b/searx/engines/__init__.py@@ -115,26 +115,26 @@ def load_engine(engine_data: dict[str, t.Any]) -> "Engine | types.ModuleType | Nlogger.error('An engine does not have a "name" field')return Noneif '_' in engine_name:- logger.error('Engine name contains underscore: "{}"'.format(engine_name))+ logger.error('Engine name contains underscore: "%s"', engine_name)return Noneif engine_name.lower() != engine_name:- logger.warning('Engine name is not lowercase: "{}", converting to lowercase'.format(engine_name))+ logger.warning('Engine name is not lowercase: "%s", converting to lowercase', engine_name)engine_name = engine_name.lower()engine_data['name'] = engine_name# load_modulemodule_name = engine_data.get('engine')if module_name is None:- logger.error('The "engine" field is missing for the engine named "{}"'.format(engine_name))+ logger.error('The "engine" field is missing for the engine named "%s"', engine_name)return Nonetry:engine = load_module(module_name + '.py', ENGINE_DIR)except (SyntaxError, KeyboardInterrupt, SystemExit, SystemError, ImportError, RuntimeError):- logger.exception('Fatal exception in engine "{}"'.format(module_name))+ logger.exception('Fatal exception in engine "%s"', module_name)sys.exit(1)except BaseException:- logger.exception('Cannot load engine "{}"'.format(module_name))+ logger.exception('Cannot load engine "%s"', module_name)return Nonecheck_engine_module(engine)@@ -247,7 +247,7 @@ def is_missing_required_attributes(engine: "Engine | types.ModuleType"):missing = Falsefor engine_attr in dir(engine):if not engine_attr.startswith('_') and getattr(engine, engine_attr) is None:- logger.error('Missing engine config attribute: "{0}.{1}"'.format(engine.name, engine_attr))+ logger.error('Missing engine config attribute: "%s.%s"', engine.name, engine_attr)missing = Truereturn missing@@ -277,12 +277,12 @@ def call_engine_setup(engine: "Engine | types.ModuleType", engine_data: dict[strif setup_func is None:setup_ok = Trueelif not callable(setup_func):- logger.error(f"engine's setup method isn't a callable (is of type: {type(setup_func)})")+ logger.error("engine's setup method isn't a callable (is of type: %s)", type(setup_func))else:try:setup_ok = engine.setup(engine_data)except Exception as e: # pylint: disable=broad-except- logger.exception(f"(PID {os.getpid()}) {engine.name}: engine SETUP failed, exception: {e}")+ logger.exception("(PID %s) %s: engine SETUP failed, exception: %s", os.getpid(), engine.name, e)setup_ok = False# The evaluation of the return value is analogous to Engine.init@@ -290,18 +290,18 @@ def call_engine_setup(engine: "Engine | types.ModuleType", engine_data: dict[strsetup_ok = Trueif not setup_ok:- logger.error(f"(PID {os.getpid()}) {engine.name}: engine setup was not successful")+ logger.error("(PID %s) %s: engine setup was not successful", os.getpid(), engine.name)return setup_okdef register_engine(engine: "Engine | types.ModuleType"):if engine.name in engines:- logger.error('Engine config error: ambiguous name: {0}'.format(engine.name))+ logger.error('Engine config error: ambiguous name: %s', engine.name)sys.exit(1)engines[engine.name] = engineif engine.shortcut in engine_shortcuts:- logger.error('Engine config error: ambiguous shortcut: {0}'.format(engine.shortcut))+ logger.error('Engine config error: ambiguous shortcut: %s', engine.shortcut)sys.exit(1)engine_shortcuts[engine.shortcut] = engine.name@@ -327,7 +327,9 @@ def load_engines(engine_list: list[dict[str, t.Any]]):# if an engine can't be loaded (if for example the engine is missing# tor or some other requirements) its set to inactive!logger.error(- f"(PID {os.getpid()}) {engine_data.get('name', '???')}: can't register engine (loading engine failed)"+ "(PID %s) %s: can't register engine (loading engine failed)",+ os.getpid(),+ engine_data.get("name", "???"),)engine_data["inactive"] = Truereturn enginesdiff --git a/searx/engines/apple_maps.py b/searx/engines/apple_maps.pyindex e725e0306..4e3cd4259 100644--- a/searx/engines/apple_maps.py+++ b/searx/engines/apple_maps.py@@ -37,8 +37,7 @@ def obtain_token():)token['value'] = loads(actual_token.text)['authInfo']['access_token']token['last_updated'] = update_time- # pylint: disable=bare-except- except:+ except: # pylint: disable=bare-exceptpassreturn tokendiff --git a/searx/engines/command.py b/searx/engines/command.pyindex d4b93d39c..09ef50c93 100644--- a/searx/engines/command.py+++ b/searx/engines/command.py@@ -169,7 +169,7 @@ def _get_results_from_process(res: EngineResults, cmd, pageno):for raw_result in raw_results:result = __parse_single_result(raw_result)if result is None:- _command_logger.debug('skipped result:', raw_result)+ _command_logger.debug('skipped result: %s', raw_result)continueif start <= count and count <= end: # pylint: disable=chained-comparisondiff --git a/searx/favicons/__init__.py b/searx/favicons/__init__.pyindex 41c6b3b9c..82e977307 100644--- a/searx/favicons/__init__.py+++ b/searx/favicons/__init__.py@@ -32,10 +32,10 @@ def init():cfg_file = (settings_loader.get_user_cfg_folder() or pathlib.Path("/etc/searxng")) / "favicons.toml"if not cfg_file.exists():if is_active():- logger.error(f"missing favicon config: {cfg_file}")+ logger.error("missing favicon config: %s", cfg_file)cfg_file = config.DEFAULT_CFG_TOML_PATH- logger.debug(f"load favicon config: {cfg_file}")+ logger.debug("load favicon config: %s", cfg_file)cfg = config.FaviconConfig.from_toml_file(cfg_file, use_cache=True)cache.init(cfg.cache)proxy.init(cfg.proxy)diff --git a/searx/favicons/cache.py b/searx/favicons/cache.pyindex f623ac3a7..2d91a8501 100644--- a/searx/favicons/cache.py+++ b/searx/favicons/cache.py@@ -352,7 +352,7 @@ CREATE TABLE IF NOT EXISTS blob_map (bytes_c = len(data or b"")if bytes_c > self.cfg.BLOB_MAX_BYTES:logger.info(- "favicon of resolver: %s / authority: %s to big to cache (bytes: %s) " % (resolver, authority, bytes_c)+ "favicon of resolver: %s / authority: %s to big to cache (bytes: %s) ", resolver, authority, bytes_c)return Falsediff --git a/searx/network/__init__.py b/searx/network/__init__.pyindex 243d746cd..0b00de59f 100644--- a/searx/network/__init__.py+++ b/searx/network/__init__.py@@ -137,7 +137,7 @@ class Request(t.NamedTuple):method: strurl: str- kwargs: dict[str, str] = {}+ kwargs: dict[str, str] = {} # pylint: disable=dangerous-default-value@staticmethoddef get(url: str, **kwargs: t.Any):diff --git a/searx/search/__init__.py b/searx/search/__init__.pyindex 45ab83509..174c3898d 100644--- a/searx/search/__init__.py+++ b/searx/search/__init__.py@@ -126,9 +126,11 @@ class Search:actual_timeout = min(query_timeout, max_request_timeout)logger.debug(- "actual_timeout={0} (default_timeout={1}, ?timeout_limit={2}, max_request_timeout={3})".format(- actual_timeout, default_timeout, query_timeout, max_request_timeout- )+ "actual_timeout=%s (default_timeout=%s, ?timeout_limit=%s, max_request_timeout=%s)",+ actual_timeout,+ default_timeout,+ query_timeout,+ max_request_timeout,)return requests, actual_timeoutdiff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.pyindex 355e23f9d..83e24ac0a 100644--- a/searx/search/processors/__init__.py+++ b/searx/search/processors/__init__.py@@ -71,7 +71,7 @@ class ProcessorMap(dict[str, EngineProcessor]):eng_type = getattr(eng_obj, "engine_type", "online")proc_cls = self.processor_types.get(eng_type)if proc_cls is None:- logger.error("Engine '%s' is of unknown engine_type: %s", eng_type)+ logger.error("Engine of name '%s' is of unknown engine_type: %s", eng_name, eng_type)continue# initialize (and register) the engine@@ -94,7 +94,7 @@ class ProcessorMap(dict[str, EngineProcessor]):# logger.debug("registered engine processor: %s", eng_proc.engine.name)else:logger.error(- f"(PID {os.getpid()}) {eng_proc.engine.name}: can't register engines processor (init engine failed)"+ "(PID %s) %s: can't register engines processor (init engine failed)", os.getpid(), eng_proc.engine.name)return eng_proc_okdiff --git a/searx/search/processors/abstract.py b/searx/search/processors/abstract.pyindex 921587f0a..7decff9d9 100644--- a/searx/search/processors/abstract.py+++ b/searx/search/processors/abstract.py@@ -161,7 +161,7 @@ class EngineProcessor(ABC):try:init_ok = self.engine.init(eng_setting)except Exception as e: # pylint: disable=broad-except- logger.exception(f"(PID {os.getpid()}) {self.engine.name}: engine INIT failed, exception: {e}")+ logger.exception("(PID %s) %s: engine INIT failed, exception: %s", os.getpid(), self.engine.name, e)init_ok = False# In older engines, None is returned from the init method, which is@@ -172,7 +172,7 @@ class EngineProcessor(ABC):init_ok = Trueif not init_ok:- logger.error(f"(PID {os.getpid()}) {self.engine.name}: engine init was not successful")+ logger.error("(PID %s) %s: engine init was not successful", os.getpid(), self.engine.name)return init_okdiff --git a/searx/webapp.py b/searx/webapp.pyindex 79587ff56..54701aa52 100755--- a/searx/webapp.py+++ b/searx/webapp.py@@ -186,7 +186,7 @@ def code_highlighter(codelines, language=None, hl_lines=None, strip_whitespace=Tlexer = get_lexer_by_name(language, stripall=strip_whitespace, stripnl=strip_new_lines)except Exception as e: # pylint: disable=broad-except- logger.warning("pygments lexer: %s " % e)+ logger.warning("pygments lexer: %s ", e)# if lexer is not found, using default onelexer = get_lexer_by_name('text', stripall=strip_whitespace, stripnl=strip_new_lines)@@ -1048,7 +1048,7 @@ def image_proxy():del respdel streamexcept RequestException as e:- logger.debug('Exception while closing response', e)+ logger.debug('Exception while closing response: %s', e)try:headers = dict_subset(resp.headers, {'Content-Type', 'Content-Encoding', 'Content-Length', 'Length'})