summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2024-03-11 14:06:26 +0100
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-03-11 14:55:38 +0100
commit542f7d0d7bd1a12e1884ba4a1508b40e2514d472 (patch)
tree5256282b267e494200d02914593457854567fec4 /searx
parent8205f170ff983e5240d32dc17d7fdb526ebe5fe7 (diff)
downloadsearxng-542f7d0d7bd1a12e1884ba4a1508b40e2514d472.tar.gz
searxng-542f7d0d7bd1a12e1884ba4a1508b40e2514d472.zip
[mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION
In the past, some files were tested with the standard profile, others with a profile in which most of the messages were switched off ... some files were not checked at all. - ``PYLINT_SEARXNG_DISABLE_OPTION`` has been abolished - the distinction ``# lint: pylint`` is no longer necessary - the pylint tasks have been reduced from three to two 1. ./searx/engines -> lint engines with additional builtins 2. ./searx ./searxng_extra ./tests -> lint all other python files Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx')
-rw-r--r--searx/__init__.py3
-rw-r--r--searx/answerers/__init__.py15
-rw-r--r--searx/answerers/random/answerer.py2
-rw-r--r--searx/answerers/statistics/answerer.py1
-rw-r--r--searx/autocomplete.py1
-rw-r--r--searx/babel_extract.py1
-rw-r--r--searx/botdetection/__init__.py1
-rw-r--r--searx/botdetection/_helpers.py1
-rw-r--r--searx/botdetection/config.py1
-rw-r--r--searx/botdetection/http_accept.py1
-rw-r--r--searx/botdetection/http_accept_encoding.py1
-rw-r--r--searx/botdetection/http_accept_language.py1
-rw-r--r--searx/botdetection/http_connection.py1
-rw-r--r--searx/botdetection/http_user_agent.py1
-rw-r--r--searx/botdetection/ip_limit.py1
-rw-r--r--searx/botdetection/ip_lists.py1
-rw-r--r--searx/botdetection/link_token.py1
-rw-r--r--searx/data/__init__.py1
-rw-r--r--searx/enginelib/__init__.py1
-rw-r--r--searx/enginelib/traits.py3
-rw-r--r--searx/engines/bandcamp.py13
-rw-r--r--searx/engines/duden.py16
-rw-r--r--searx/engines/presearch.py3
-rw-r--r--searx/exceptions.py2
-rw-r--r--searx/external_bang.py3
-rw-r--r--searx/external_urls.py6
-rw-r--r--searx/flaskfix.py1
-rw-r--r--searx/infopage/__init__.py2
-rw-r--r--searx/limiter.py1
-rw-r--r--searx/locales.py2
-rw-r--r--searx/metrics/__init__.py1
-rw-r--r--searx/metrics/error_recorder.py15
-rw-r--r--searx/metrics/models.py29
-rw-r--r--searx/network/__init__.py1
-rw-r--r--searx/network/client.py1
-rw-r--r--searx/network/network.py1
-rw-r--r--searx/network/raise_for_httperror.py1
-rw-r--r--searx/plugins/__init__.py1
-rw-r--r--searx/plugins/ahmia_filter.py9
-rw-r--r--searx/plugins/hash_plugin.py26
-rw-r--r--searx/plugins/hostname_replace.py7
-rw-r--r--searx/plugins/oa_doi_rewrite.py9
-rw-r--r--searx/plugins/self_info.py1
-rw-r--r--searx/plugins/tor_check.py1
-rw-r--r--searx/plugins/tracker_url_remover.py23
-rw-r--r--searx/preferences.py1
-rw-r--r--searx/query.py3
-rw-r--r--searx/redisdb.py1
-rw-r--r--searx/redislib.py1
-rw-r--r--searx/results.py30
-rw-r--r--searx/search/__init__.py1
-rw-r--r--searx/search/checker/__init__.py1
-rw-r--r--searx/search/checker/__main__.py1
-rw-r--r--searx/search/checker/background.py4
-rw-r--r--searx/search/checker/impl.py12
-rw-r--r--searx/search/checker/scheduler.py1
-rw-r--r--searx/search/models.py3
-rw-r--r--searx/search/processors/__init__.py1
-rw-r--r--searx/search/processors/abstract.py2
-rw-r--r--searx/search/processors/offline.py2
-rw-r--r--searx/search/processors/online.py2
-rw-r--r--searx/search/processors/online_currency.py1
-rw-r--r--searx/search/processors/online_dictionary.py1
-rw-r--r--searx/search/processors/online_url_search.py1
-rw-r--r--searx/settings_defaults.py1
-rw-r--r--searx/settings_loader.py1
-rw-r--r--searx/sxng_locales.py2
-rw-r--r--searx/unixthreadname.py1
-rw-r--r--searx/utils.py6
-rw-r--r--searx/version.py2
-rw-r--r--searx/webadapter.py14
-rwxr-xr-xsearx/webapp.py2
-rw-r--r--searx/webutils.py19
73 files changed, 126 insertions, 205 deletions
diff --git a/searx/__init__.py b/searx/__init__.py
index d611ef6a2..7bda2d7f8 100644
--- a/searx/__init__.py
+++ b/searx/__init__.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-# pylint: disable=missing-module-docstring
+# pylint: disable=missing-module-docstring, cyclic-import
import sys
import os
diff --git a/searx/answerers/__init__.py b/searx/answerers/__init__.py
index 8e2b9b35a..346bbb085 100644
--- a/searx/answerers/__init__.py
+++ b/searx/answerers/__init__.py
@@ -1,25 +1,30 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
+import sys
from os import listdir
from os.path import realpath, dirname, join, isdir
-from searx.utils import load_module
from collections import defaultdict
+from searx.utils import load_module
answerers_dir = dirname(realpath(__file__))
def load_answerers():
- answerers = []
+ answerers = [] # pylint: disable=redefined-outer-name
+
for filename in listdir(answerers_dir):
if not isdir(join(answerers_dir, filename)) or filename.startswith('_'):
continue
module = load_module('answerer.py', join(answerers_dir, filename))
- if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not len(module.keywords):
- exit(2)
+ if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not module.keywords:
+ sys.exit(2)
answerers.append(module)
return answerers
-def get_answerers_by_keywords(answerers):
+def get_answerers_by_keywords(answerers): # pylint:disable=redefined-outer-name
by_keyword = defaultdict(list)
for answerer in answerers:
for keyword in answerer.keywords:
diff --git a/searx/answerers/random/answerer.py b/searx/answerers/random/answerer.py
index a1306e2eb..efdce0407 100644
--- a/searx/answerers/random/answerer.py
+++ b/searx/answerers/random/answerer.py
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
import hashlib
import random
import string
diff --git a/searx/answerers/statistics/answerer.py b/searx/answerers/statistics/answerer.py
index 60f0d304f..3c38243de 100644
--- a/searx/answerers/statistics/answerer.py
+++ b/searx/answerers/statistics/answerer.py
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
from functools import reduce
from operator import mul
diff --git a/searx/autocomplete.py b/searx/autocomplete.py
index 49e1eaa6a..e277c6631 100644
--- a/searx/autocomplete.py
+++ b/searx/autocomplete.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""This module implements functions needed for the autocompleter.
"""
diff --git a/searx/babel_extract.py b/searx/babel_extract.py
index 5bcb1f0e9..f50756a48 100644
--- a/searx/babel_extract.py
+++ b/searx/babel_extract.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""This module implements the :origin:`searxng_msg <babel.cfg>` extractor to
extract messages from:
diff --git a/searx/botdetection/__init__.py b/searx/botdetection/__init__.py
index d5716bcc8..51f437cf0 100644
--- a/searx/botdetection/__init__.py
+++ b/searx/botdetection/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
""".. _botdetection src:
Implementations used for bot detection.
diff --git a/searx/botdetection/_helpers.py b/searx/botdetection/_helpers.py
index 365067c24..5387fe5cc 100644
--- a/searx/botdetection/_helpers.py
+++ b/searx/botdetection/_helpers.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring, invalid-name
from __future__ import annotations
diff --git a/searx/botdetection/config.py b/searx/botdetection/config.py
index b705f34d2..d7e3426cf 100644
--- a/searx/botdetection/config.py
+++ b/searx/botdetection/config.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Configuration class :py:class:`Config` with deep-update, schema validation
and deprecated names.
diff --git a/searx/botdetection/http_accept.py b/searx/botdetection/http_accept.py
index b1f524593..911309ebe 100644
--- a/searx/botdetection/http_accept.py
+++ b/searx/botdetection/http_accept.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``http_accept``
----------------------
diff --git a/searx/botdetection/http_accept_encoding.py b/searx/botdetection/http_accept_encoding.py
index e0c03cc73..4f9e28858 100644
--- a/searx/botdetection/http_accept_encoding.py
+++ b/searx/botdetection/http_accept_encoding.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``http_accept_encoding``
-------------------------------
diff --git a/searx/botdetection/http_accept_language.py b/searx/botdetection/http_accept_language.py
index aaef81cc4..e351d03cb 100644
--- a/searx/botdetection/http_accept_language.py
+++ b/searx/botdetection/http_accept_language.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``http_accept_language``
-------------------------------
diff --git a/searx/botdetection/http_connection.py b/searx/botdetection/http_connection.py
index a32877158..c720b55e6 100644
--- a/searx/botdetection/http_connection.py
+++ b/searx/botdetection/http_connection.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``http_connection``
--------------------------
diff --git a/searx/botdetection/http_user_agent.py b/searx/botdetection/http_user_agent.py
index 9e45c7f9d..db6356449 100644
--- a/searx/botdetection/http_user_agent.py
+++ b/searx/botdetection/http_user_agent.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``http_user_agent``
--------------------------
diff --git a/searx/botdetection/ip_limit.py b/searx/botdetection/ip_limit.py
index 387e580ee..757314f0e 100644
--- a/searx/botdetection/ip_limit.py
+++ b/searx/botdetection/ip_limit.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
""".. _botdetection.ip_limit:
Method ``ip_limit``
diff --git a/searx/botdetection/ip_lists.py b/searx/botdetection/ip_lists.py
index c94f2a6e8..2ad1c62d0 100644
--- a/searx/botdetection/ip_lists.py
+++ b/searx/botdetection/ip_lists.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
""".. _botdetection.ip_lists:
Method ``ip_lists``
diff --git a/searx/botdetection/link_token.py b/searx/botdetection/link_token.py
index dcfee33d9..7a484d6d5 100644
--- a/searx/botdetection/link_token.py
+++ b/searx/botdetection/link_token.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
Method ``link_token``
---------------------
diff --git a/searx/data/__init__.py b/searx/data/__init__.py
index c79d1042f..28a3974fa 100644
--- a/searx/data/__init__.py
+++ b/searx/data/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""This module holds the *data* created by::
make data.all
diff --git a/searx/enginelib/__init__.py b/searx/enginelib/__init__.py
index 263ebd23c..6e6c24cb7 100644
--- a/searx/enginelib/__init__.py
+++ b/searx/enginelib/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Implementations of the framework for the SearXNG engines.
.. hint::
diff --git a/searx/enginelib/traits.py b/searx/enginelib/traits.py
index e1a5df79a..cab6557dd 100644
--- a/searx/enginelib/traits.py
+++ b/searx/enginelib/traits.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Engine's traits are fetched from the origin engines and stored in a JSON file
in the *data folder*. Most often traits are languages and region codes and
their mapping from SearXNG's representation to the representation in the origin
@@ -167,7 +166,7 @@ class EngineTraits:
# - name: google italian
# engine: google
# language: it
- # region: it-IT
+ # region: it-IT # type: ignore
traits = self.copy()
diff --git a/searx/engines/bandcamp.py b/searx/engines/bandcamp.py
index 382e32e30..b79b0df3e 100644
--- a/searx/engines/bandcamp.py
+++ b/searx/engines/bandcamp.py
@@ -37,16 +37,6 @@ iframe_src = "https://bandcamp.com/EmbeddedPlayer/{type}={result_id}/size=large/
def request(query, params):
- '''pre-request callback
-
- params<dict>:
- method : POST/GET
- headers : {}
- data : {} # if method == POST
- url : ''
- category: 'search category'
- pageno : 1 # number of the requested page
- '''
search_path = search_string.format(query=urlencode({'q': query}), page=params['pageno'])
params['url'] = base_url + search_path
@@ -54,10 +44,7 @@ def request(query, params):
def response(resp):
- '''post-response callback
- resp: requests response object
- '''
results = []
dom = html.fromstring(resp.text)
diff --git a/searx/engines/duden.py b/searx/engines/duden.py
index dca566404..94dff71ef 100644
--- a/searx/engines/duden.py
+++ b/searx/engines/duden.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-"""
- Duden
+"""Duden
+
"""
import re
@@ -29,15 +29,6 @@ search_url = base_url + 'suchen/dudenonline/{query}?search_api_fulltext=&page={o
def request(query, params):
- '''pre-request callback
- params<dict>:
- method : POST/GET
- headers : {}
- data : {} # if method == POST
- url : ''
- category: 'search category'
- pageno : 1 # number of the requested page
- '''
offset = params['pageno'] - 1
if offset == 0:
@@ -53,9 +44,6 @@ def request(query, params):
def response(resp):
- '''post-response callback
- resp: requests response object
- '''
results = []
if resp.status_code == 404:
diff --git a/searx/engines/presearch.py b/searx/engines/presearch.py
index 88fa59f0e..1af32ac85 100644
--- a/searx/engines/presearch.py
+++ b/searx/engines/presearch.py
@@ -120,8 +120,7 @@ def _get_request_id(query, params):
l = locales.get_locale(params['searxng_locale'])
# Presearch narrows down the search by region. In SearXNG when the user
- # does not set a region (e.g. 'en-CA' / canada) we cannot hand over a
- # region.
+ # does not set a region (e.g. 'en-CA' / canada) we cannot hand over a region.
# We could possibly use searx.locales.get_official_locales to determine
# in which regions this language is an official one, but then we still
diff --git a/searx/exceptions.py b/searx/exceptions.py
index ac8eb6314..77c3f998d 100644
--- a/searx/exceptions.py
+++ b/searx/exceptions.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Exception types raised by SearXNG modules.
"""
diff --git a/searx/external_bang.py b/searx/external_bang.py
index 0336d880b..fde2f8eb5 100644
--- a/searx/external_bang.py
+++ b/searx/external_bang.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from urllib.parse import quote_plus, urlparse
from searx.data import EXTERNAL_BANGS
@@ -53,7 +54,7 @@ def resolve_bang_definition(bang_definition, query):
return (url, rank)
-def get_bang_definition_and_autocomplete(bang, external_bangs_db=None):
+def get_bang_definition_and_autocomplete(bang, external_bangs_db=None): # pylint: disable=invalid-name
if external_bangs_db is None:
external_bangs_db = EXTERNAL_BANGS
diff --git a/searx/external_urls.py b/searx/external_urls.py
index 7844b58d0..8e243ec47 100644
--- a/searx/external_urls.py
+++ b/searx/external_urls.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
import math
from searx.data import EXTERNAL_URLS
@@ -46,8 +49,7 @@ def get_external_url(url_id, item_id, alternative="default"):
if url_template is not None:
if item_id is not None:
return url_template.replace('$1', item_id)
- else:
- return url_template
+ return url_template
return None
diff --git a/searx/flaskfix.py b/searx/flaskfix.py
index 326c4b981..f2a54bdfc 100644
--- a/searx/flaskfix.py
+++ b/searx/flaskfix.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring
from urllib.parse import urlparse
diff --git a/searx/infopage/__init__.py b/searx/infopage/__init__.py
index 9ba0ea517..3f9426beb 100644
--- a/searx/infopage/__init__.py
+++ b/searx/infopage/__init__.py
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-# pyright: basic
"""Render SearXNG instance documentation.
Usage in a Flask app route:
diff --git a/searx/limiter.py b/searx/limiter.py
index fa7418922..08326b42e 100644
--- a/searx/limiter.py
+++ b/searx/limiter.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Bot protection / IP rate limitation. The intention of rate limitation is to
limit suspicious requests from an IP. The motivation behind this is the fact
that SearXNG passes through requests from bots and is thus classified as a bot
diff --git a/searx/locales.py b/searx/locales.py
index c2fa030b1..ea9af9438 100644
--- a/searx/locales.py
+++ b/searx/locales.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
SearXNG’s locale data
=====================
diff --git a/searx/metrics/__init__.py b/searx/metrics/__init__.py
index da33025dc..d7ccee91a 100644
--- a/searx/metrics/__init__.py
+++ b/searx/metrics/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring
import typing
diff --git a/searx/metrics/error_recorder.py b/searx/metrics/error_recorder.py
index 1d0d6e7a3..df25e8d41 100644
--- a/searx/metrics/error_recorder.py
+++ b/searx/metrics/error_recorder.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
+
import typing
import inspect
from json import JSONDecodeError
@@ -16,7 +19,7 @@ from searx.engines import engines
errors_per_engines = {}
-class ErrorContext:
+class ErrorContext: # pylint: disable=missing-class-docstring
__slots__ = (
'filename',
@@ -29,7 +32,9 @@ class ErrorContext:
'secondary',
)
- def __init__(self, filename, function, line_no, code, exception_classname, log_message, log_parameters, secondary):
+ def __init__( # pylint: disable=too-many-arguments
+ self, filename, function, line_no, code, exception_classname, log_message, log_parameters, secondary
+ ):
self.filename = filename
self.function = function
self.line_no = line_no
@@ -39,7 +44,7 @@ class ErrorContext:
self.log_parameters = log_parameters
self.secondary = secondary
- def __eq__(self, o) -> bool:
+ def __eq__(self, o) -> bool: # pylint: disable=invalid-name
if not isinstance(o, ErrorContext):
return False
return (
@@ -109,7 +114,7 @@ def get_request_exception_messages(
status_code = None
reason = None
hostname = None
- if hasattr(exc, '_request') and exc._request is not None:
+ if hasattr(exc, '_request') and exc._request is not None: # pylint: disable=protected-access
# exc.request is property that raise an RuntimeException
# if exc._request is not defined.
url = exc.request.url
@@ -123,7 +128,7 @@ def get_request_exception_messages(
return (status_code, reason, hostname)
-def get_messages(exc, filename) -> typing.Tuple:
+def get_messages(exc, filename) -> typing.Tuple: # pylint: disable=too-many-return-statements
if isinstance(exc, JSONDecodeError):
return (exc.msg,)
if isinstance(exc, TypeError):
diff --git a/searx/metrics/models.py b/searx/metrics/models.py
index 900a7fa93..b3ef582e0 100644
--- a/searx/metrics/models.py
+++ b/searx/metrics/models.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
import decimal
import threading
@@ -11,7 +12,7 @@ __all__ = ["Histogram", "HistogramStorage", "CounterStorage"]
logger = logger.getChild('searx.metrics')
-class Histogram:
+class Histogram: # pylint: disable=missing-class-docstring
_slots__ = '_lock', '_size', '_sum', '_quartiles', '_count', '_width'
@@ -25,11 +26,11 @@ class Histogram:
def observe(self, value):
q = int(value / self._width)
- if q < 0:
- """Value below zero is ignored"""
+ if q < 0: # pylint: disable=consider-using-max-builtin
+ # Value below zero is ignored
q = 0
if q >= self._size:
- """Value above the maximum is replaced by the maximum"""
+ # Value above the maximum is replaced by the maximum
q = self._size - 1
with self._lock:
self._quartiles[q] += 1
@@ -53,8 +54,7 @@ class Histogram:
with self._lock:
if self._count != 0:
return self._sum / self._count
- else:
- return 0
+ return 0
@property
def quartile_percentage(self):
@@ -62,8 +62,7 @@ class Histogram:
with self._lock:
if self._count > 0:
return [int(q * 100 / self._count) for q in self._quartiles]
- else:
- return self._quartiles
+ return self._quartiles
@property
def quartile_percentage_map(self):
@@ -75,7 +74,7 @@ class Histogram:
with self._lock:
if self._count > 0:
for y in self._quartiles:
- yp = int(y * 100 / self._count)
+ yp = int(y * 100 / self._count) # pylint: disable=invalid-name
if yp != 0:
result[round(float(x), width_exponent)] = yp
x += width
@@ -100,7 +99,7 @@ class Histogram:
return "Histogram<avg: " + str(self.average) + ", count: " + str(self._count) + ">"
-class HistogramStorage:
+class HistogramStorage: # pylint: disable=missing-class-docstring
__slots__ = 'measures', 'histogram_class'
@@ -121,12 +120,12 @@ class HistogramStorage:
def dump(self):
logger.debug("Histograms:")
- ks = sorted(self.measures.keys(), key='/'.join)
+ ks = sorted(self.measures.keys(), key='/'.join) # pylint: disable=invalid-name
for k in ks:
logger.debug("- %-60s %s", '|'.join(k), self.measures[k])
-class CounterStorage:
+class CounterStorage: # pylint: disable=missing-class-docstring
__slots__ = 'counters', 'lock'
@@ -151,17 +150,17 @@ class CounterStorage:
def dump(self):
with self.lock:
- ks = sorted(self.counters.keys(), key='/'.join)
+ ks = sorted(self.counters.keys(), key='/'.join) # pylint: disable=invalid-name
logger.debug("Counters:")
for k in ks:
logger.debug("- %-60s %s", '|'.join(k), self.counters[k])
-class VoidHistogram(Histogram):
+class VoidHistogram(Histogram): # pylint: disable=missing-class-docstring
def observe(self, value):
pass
-class VoidCounterStorage(CounterStorage):
+class VoidCounterStorage(CounterStorage): # pylint: disable=missing-class-docstring
def add(self, value, *args):
pass
diff --git a/searx/network/__init__.py b/searx/network/__init__.py
index 67028f5f0..8e1edb4d0 100644
--- a/searx/network/__init__.py
+++ b/searx/network/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring, global-statement
import asyncio
diff --git a/searx/network/client.py b/searx/network/client.py
index 23826c75d..32bc5af42 100644
--- a/searx/network/client.py
+++ b/searx/network/client.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring, global-statement
import asyncio
diff --git a/searx/network/network.py b/searx/network/network.py
index 0cdfb1c43..453c8d2fc 100644
--- a/searx/network/network.py
+++ b/searx/network/network.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=global-statement
# pylint: disable=missing-module-docstring, missing-class-docstring
diff --git a/searx/network/raise_for_httperror.py b/searx/network/raise_for_httperror.py
index 9f847d436..abee2c78b 100644
--- a/searx/network/raise_for_httperror.py
+++ b/searx/network/raise_for_httperror.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Raise exception for an HTTP response is an error.
"""
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py
index 41dd1a0ef..c3aad5f32 100644
--- a/searx/plugins/__init__.py
+++ b/searx/plugins/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring, missing-class-docstring
import sys
diff --git a/searx/plugins/ahmia_filter.py b/searx/plugins/ahmia_filter.py
index 326da9ca1..bbf137103 100644
--- a/searx/plugins/ahmia_filter.py
+++ b/searx/plugins/ahmia_filter.py
@@ -1,6 +1,5 @@
-'''
- SPDX-License-Identifier: AGPL-3.0-or-later
-'''
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from hashlib import md5
from searx.data import ahmia_blacklist_loader
@@ -13,14 +12,14 @@ preference_section = 'onions'
ahmia_blacklist = None
-def on_result(request, search, result):
+def on_result(_request, _search, result):
if not result.get('is_onion') or not result.get('parsed_url'):
return True
result_hash = md5(result['parsed_url'].hostname.encode()).hexdigest()
return result_hash not in ahmia_blacklist
-def init(app, settings):
+def init(_app, settings):
global ahmia_blacklist # pylint: disable=global-statement
if not settings['outgoing']['using_tor_proxy']:
# disable the plugin
diff --git a/searx/plugins/hash_plugin.py b/searx/plugins/hash_plugin.py
index edb91dd8e..c27e2a432 100644
--- a/searx/plugins/hash_plugin.py
+++ b/searx/plugins/hash_plugin.py
@@ -1,25 +1,11 @@
-'''
-searx is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
-searx is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with searx. If not, see < http://www.gnu.org/licenses/ >.
-
-(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
-(C) 2018, 2020 by Vaclav Zouzalik
-'''
-
-from flask_babel import gettext
import hashlib
import re
+from flask_babel import gettext
+
name = "Hash plugin"
description = gettext("Converts strings to different hash digests.")
default_on = True
@@ -30,7 +16,7 @@ query_examples = 'sha512 The quick brown fox jumps over the lazy dog'
parser_re = re.compile('(md5|sha1|sha224|sha256|sha384|sha512) (.*)', re.I)
-def post_search(request, search):
+def post_search(_request, search):
# process only on first page
if search.search_query.pageno > 1:
return True
@@ -40,7 +26,7 @@ def post_search(request, search):
return True
function, string = m.groups()
- if string.strip().__len__() == 0:
+ if not string.strip():
# end if the string is empty
return True
diff --git a/searx/plugins/hostname_replace.py b/searx/plugins/hostname_replace.py
index 5a1df6921..1b3f8609c 100644
--- a/searx/plugins/hostname_replace.py
+++ b/searx/plugins/hostname_replace.py
@@ -1,10 +1,13 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
import re
from urllib.parse import urlunparse, urlparse
+
+from flask_babel import gettext
+
from searx import settings
from searx.plugins import logger
-from flask_babel import gettext
name = gettext('Hostname replace')
description = gettext('Rewrite result hostnames or remove results based on the hostname')
@@ -20,7 +23,7 @@ parsed = 'parsed_url'
_url_fields = ['iframe_src', 'audio_src']
-def on_result(request, search, result):
+def on_result(_request, _search, result):
for pattern, replacement in replacements.items():
diff --git a/searx/plugins/oa_doi_rewrite.py b/searx/plugins/oa_doi_rewrite.py
index f0e07735d..6a214282c 100644
--- a/searx/plugins/oa_doi_rewrite.py
+++ b/searx/plugins/oa_doi_rewrite.py
@@ -1,9 +1,12 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
+import re
from urllib.parse import urlparse, parse_qsl
+
from flask_babel import gettext
-import re
from searx import settings
-
regex = re.compile(r'10\.\d{4,9}/[^\s]+')
name = gettext('Open Access DOI rewrite')
@@ -31,7 +34,7 @@ def get_doi_resolver(preferences):
return doi_resolvers[selected_resolver]
-def on_result(request, search, result):
+def on_result(request, _search, result):
if 'parsed_url' not in result:
return True
diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py
index 8079ee0d4..75a2a76c9 100644
--- a/searx/plugins/self_info.py
+++ b/searx/plugins/self_info.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring,invalid-name
import re
diff --git a/searx/plugins/tor_check.py b/searx/plugins/tor_check.py
index 831c90ce5..3816d8ece 100644
--- a/searx/plugins/tor_check.py
+++ b/searx/plugins/tor_check.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""A plugin to check if the ip address of the request is a Tor exit-node if the
user searches for ``tor-check``. It fetches the tor exit node list from
https://check.torproject.org/exit-addresses and parses all the IPs into a list,
diff --git a/searx/plugins/tracker_url_remover.py b/searx/plugins/tracker_url_remover.py
index 42c58e524..2961cd026 100644
--- a/searx/plugins/tracker_url_remover.py
+++ b/searx/plugins/tracker_url_remover.py
@@ -1,24 +1,11 @@
-'''
-searx is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
-searx is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with searx. If not, see < http://www.gnu.org/licenses/ >.
-
-(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
-'''
-
-from flask_babel import gettext
import re
from urllib.parse import urlunparse, parse_qsl, urlencode
+from flask_babel import gettext
+
regexes = {
re.compile(r'utm_[^&]+'),
re.compile(r'(wkey|wemail)[^&]*'),
@@ -32,7 +19,7 @@ default_on = True
preference_section = 'privacy'
-def on_result(request, search, result):
+def on_result(_request, _search, result):
if 'parsed_url' not in result:
return True
diff --git a/searx/preferences.py b/searx/preferences.py
index da486b0cb..b4a10899e 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Searx preferences implementation.
"""
diff --git a/searx/query.py b/searx/query.py
index 49fa89a9c..ae68d0da2 100644
--- a/searx/query.py
+++ b/searx/query.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=invalid-name, missing-module-docstring, missing-class-docstring
from abc import abstractmethod, ABC
import re
@@ -191,7 +192,7 @@ class BangParser(QueryPartParser):
def _parse(self, value):
# check if prefix is equal with engine shortcut
- if value in engine_shortcuts:
+ if value in engine_shortcuts: # pylint: disable=consider-using-get
value = engine_shortcuts[value]
# check if prefix is equal with engine name
diff --git a/searx/redisdb.py b/searx/redisdb.py
index 0544d697f..bed0c347b 100644
--- a/searx/redisdb.py
+++ b/searx/redisdb.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Implementation of the redis client (redis-py_).
.. _redis-py: https://github.com/redis/redis-py
diff --git a/searx/redislib.py b/searx/redislib.py
index d65212b8c..5fa8f2dae 100644
--- a/searx/redislib.py
+++ b/searx/redislib.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""A collection of convenient functions and redis/lua scripts.
This code was partial inspired by the `Bullet-Proofing Lua Scripts in RedisPy`_
diff --git a/searx/results.py b/searx/results.py
index a941fdfba..023d2edf6 100644
--- a/searx/results.py
+++ b/searx/results.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
import re
from collections import defaultdict
from operator import itemgetter
@@ -19,8 +22,7 @@ WHITESPACE_REGEX = re.compile('( |\t|\n)+', re.M | re.U)
def result_content_len(content):
if isinstance(content, str):
return len(CONTENT_LEN_IGNORED_CHARS_REGEX.sub('', content))
- else:
- return 0
+ return 0
def compare_urls(url_a, url_b):
@@ -56,7 +58,7 @@ def compare_urls(url_a, url_b):
return unquote(path_a) == unquote(path_b)
-def merge_two_infoboxes(infobox1, infobox2):
+def merge_two_infoboxes(infobox1, infobox2): # pylint: disable=too-many-branches, too-many-statements
# get engines weights
if hasattr(engines[infobox1['engine']], 'weight'):
weight1 = engines[infobox1['engine']].weight
@@ -140,13 +142,13 @@ def result_score(result):
return sum((occurrences * weight) / position for position in result['positions'])
-class Timing(NamedTuple):
+class Timing(NamedTuple): # pylint: disable=missing-class-docstring
engine: str
total: float
load: float
-class UnresponsiveEngine(NamedTuple):
+class UnresponsiveEngine(NamedTuple): # pylint: disable=missing-class-docstring
engine: str
error_type: str
suspended: bool
@@ -189,7 +191,7 @@ class ResultContainer:
self.on_result = lambda _: True
self._lock = RLock()
- def extend(self, engine_name, results):
+ def extend(self, engine_name, results): # pylint: disable=too-many-branches
if self._closed:
return
@@ -314,11 +316,11 @@ class ResultContainer:
if result_template != 'images.html':
# not an image, same template, same url : it's a duplicate
return merged_result
- else:
- # it's an image
- # it's a duplicate if the parsed_url, template and img_src are different
- if result.get('img_src', '') == merged_result.get('img_src', ''):
- return merged_result
+
+ # it's an image
+ # it's a duplicate if the parsed_url, template and img_src are different
+ if result.get('img_src', '') == merged_result.get('img_src', ''):
+ return merged_result
return None
def __merge_duplicated_http_result(self, duplicated, result, position):
@@ -371,11 +373,11 @@ class ResultContainer:
categoryPositions = {}
for res in results:
- # FIXME : handle more than one category per engine
+ # do we need to handle more than one category per engine?
engine = engines[res['engine']]
res['category'] = engine.categories[0] if len(engine.categories) > 0 else ''
- # FIXME : handle more than one category per engine
+ # do we need to handle more than one category per engine?
category = (
res['category']
+ ':'
@@ -397,7 +399,7 @@ class ResultContainer:
# update every index after the current one
# (including the current one)
- for k in categoryPositions:
+ for k in categoryPositions: # pylint: disable=consider-using-dict-items
v = categoryPositions[k]['index']
if v >= index:
categoryPositions[k]['index'] = v + 1
diff --git a/searx/search/__init__.py b/searx/search/__init__.py
index fcdc1f72f..f0cd6765f 100644
--- a/searx/search/__init__.py
+++ b/searx/search/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring, too-few-public-methods
import threading
diff --git a/searx/search/checker/__init__.py b/searx/search/checker/__init__.py
index 7d779a282..f6891a5db 100644
--- a/searx/search/checker/__init__.py
+++ b/searx/search/checker/__init__.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from .impl import Checker
from .background import initialize, get_result
diff --git a/searx/search/checker/__main__.py b/searx/search/checker/__main__.py
index 340c27187..984c8526c 100644
--- a/searx/search/checker/__main__.py
+++ b/searx/search/checker/__main__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring
import sys
diff --git a/searx/search/checker/background.py b/searx/search/checker/background.py
index f16e4c25c..5e9d23e00 100644
--- a/searx/search/checker/background.py
+++ b/searx/search/checker/background.py
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-# pylint: disable=missing-module-docstring
-# pyright: basic
+# pylint: disable=missing-module-docstring, cyclic-import
import json
import time
diff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.py
index b5dff1fd2..cf1f03449 100644
--- a/searx/search/checker/impl.py
+++ b/searx/search/checker/impl.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
import gc
import typing
@@ -149,7 +150,7 @@ def _search_query_diff(
return (common, diff)
-class TestResults:
+class TestResults: # pylint: disable=missing-class-docstring
__slots__ = 'errors', 'logs', 'languages'
@@ -181,7 +182,7 @@ class TestResults:
yield (test_name, error)
-class ResultContainerTests:
+class ResultContainerTests: # pylint: disable=missing-class-docstring
__slots__ = 'test_name', 'search_query', 'result_container', 'languages', 'stop_test', 'test_results'
@@ -210,7 +211,6 @@ class ResultContainerTests:
if langStr:
self.languages.add(langStr)
self.test_results.add_language(langStr)
- return None
def _check_result(self, result):
if not _check_no_html(result.get('title', '')):
@@ -319,7 +319,7 @@ class ResultContainerTests:
self._record_error(('{!r} not found in the title'.format(title)))
-class CheckerTests:
+class CheckerTests: # pylint: disable=missing-class-docstring, too-few-public-methods
__slots__ = 'test_results', 'test_name', 'result_container_tests_list'
@@ -351,7 +351,7 @@ class CheckerTests:
)
-class Checker:
+class Checker: # pylint: disable=missing-class-docstring
__slots__ = 'processor', 'tests', 'test_results'
@@ -377,7 +377,7 @@ class Checker:
p.append(l)
for kwargs in itertools.product(*p):
- kwargs = {k: v for k, v in kwargs}
+ kwargs = dict(kwargs)
query = kwargs['query']
params = dict(kwargs)
del params['query']
diff --git a/searx/search/checker/scheduler.py b/searx/search/checker/scheduler.py
index 7d7e90769..c0d3f799a 100644
--- a/searx/search/checker/scheduler.py
+++ b/searx/search/checker/scheduler.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring
"""Lame scheduler which use Redis as a source of truth:
* the Redis key SearXNG_checker_next_call_ts contains the next time the embedded checker should run.
diff --git a/searx/search/models.py b/searx/search/models.py
index ec1188fbb..62424390f 100644
--- a/searx/search/models.py
+++ b/searx/search/models.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
import typing
import babel
@@ -52,7 +53,7 @@ class SearchQuery:
external_bang: typing.Optional[str] = None,
engine_data: typing.Optional[typing.Dict[str, str]] = None,
redirect_to_first_result: typing.Optional[bool] = None,
- ):
+ ): # pylint:disable=too-many-arguments
self.query = query
self.engineref_list = engineref_list
self.lang = lang
diff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.py
index 6d2f97fbb..ea049e79f 100644
--- a/searx/search/processors/__init__.py
+++ b/searx/search/processors/__init__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Implement request processors used by engine-types.
diff --git a/searx/search/processors/abstract.py b/searx/search/processors/abstract.py
index baa031a06..f89302a92 100644
--- a/searx/search/processors/abstract.py
+++ b/searx/search/processors/abstract.py
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-
"""Abstract base classes for engine request processors.
"""
diff --git a/searx/search/processors/offline.py b/searx/search/processors/offline.py
index ca5b9f050..8835bfbf2 100644
--- a/searx/search/processors/offline.py
+++ b/searx/search/processors/offline.py
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-
"""Processors for engine-type: ``offline``
"""
diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py
index 9c821bb5f..acc3792f5 100644
--- a/searx/search/processors/online.py
+++ b/searx/search/processors/online.py
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-
"""Processors for engine-type: ``online``
"""
diff --git a/searx/search/processors/online_currency.py b/searx/search/processors/online_currency.py
index eb242a9f6..7d6811e6b 100644
--- a/searx/search/processors/online_currency.py
+++ b/searx/search/processors/online_currency.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Processors for engine-type: ``online_currency``
"""
diff --git a/searx/search/processors/online_dictionary.py b/searx/search/processors/online_dictionary.py
index 92a688fab..968c180d0 100644
--- a/searx/search/processors/online_dictionary.py
+++ b/searx/search/processors/online_dictionary.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Processors for engine-type: ``online_dictionary``
"""
diff --git a/searx/search/processors/online_url_search.py b/searx/search/processors/online_url_search.py
index 9c8890767..3db970df0 100644
--- a/searx/search/processors/online_url_search.py
+++ b/searx/search/processors/online_url_search.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Processors for engine-type: ``online_url_search``
"""
diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py
index 81e30bb4a..93b04257c 100644
--- a/searx/settings_defaults.py
+++ b/searx/settings_defaults.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Implementation of the default settings.
"""
diff --git a/searx/settings_loader.py b/searx/settings_loader.py
index 6983c3ab0..fe2696cce 100644
--- a/searx/settings_loader.py
+++ b/searx/settings_loader.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, too-many-branches
from typing import Optional
from os import environ
diff --git a/searx/sxng_locales.py b/searx/sxng_locales.py
index 27f892386..0c45d05c1 100644
--- a/searx/sxng_locales.py
+++ b/searx/sxng_locales.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
'''List of SearXNG's locale codes.
.. hint::
diff --git a/searx/unixthreadname.py b/searx/unixthreadname.py
index 3c2a68917..b335b1650 100644
--- a/searx/unixthreadname.py
+++ b/searx/unixthreadname.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""
if setproctitle is installed.
set Unix thread name with the Python thread name
diff --git a/searx/utils.py b/searx/utils.py
index 259a14df3..cd0e20260 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-# pyright: basic
"""Utility functions for the engines
"""
@@ -56,7 +54,7 @@ _STORAGE_UNIT_VALUE: Dict[str, int] = {
_XPATH_CACHE: Dict[str, XPath] = {}
_LANG_TO_LC_CACHE: Dict[str, Dict[str, str]] = {}
-_FASTTEXT_MODEL: Optional["fasttext.FastText._FastText"] = None
+_FASTTEXT_MODEL: Optional["fasttext.FastText._FastText"] = None # type: ignore
"""fasttext model to predict laguage of a search term"""
SEARCH_LANGUAGE_CODES = frozenset([searxng_locale[0].split('-')[0] for searxng_locale in sxng_locales])
@@ -595,7 +593,7 @@ def eval_xpath_getindex(elements: ElementBase, xpath_spec: XPathSpecType, index:
return default
-def _get_fasttext_model() -> "fasttext.FastText._FastText":
+def _get_fasttext_model() -> "fasttext.FastText._FastText": # type: ignore
global _FASTTEXT_MODEL # pylint: disable=global-statement
if _FASTTEXT_MODEL is None:
import fasttext # pylint: disable=import-outside-toplevel
diff --git a/searx/version.py b/searx/version.py
index 2931b6af4..d2013808b 100644
--- a/searx/version.py
+++ b/searx/version.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=,missing-module-docstring,missing-class-docstring
import os
@@ -108,6 +107,7 @@ if __name__ == "__main__":
if len(sys.argv) >= 2 and sys.argv[1] == "freeze":
# freeze the version (to create an archive outside a git repository)
python_code = f"""# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
# this file is generated automatically by searx/version.py
VERSION_STRING = "{VERSION_STRING}"
diff --git a/searx/webadapter.py b/searx/webadapter.py
index 9fbb8ea3e..53d9bfa89 100644
--- a/searx/webadapter.py
+++ b/searx/webadapter.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
from collections import defaultdict
from typing import Dict, List, Optional, Tuple
from searx.exceptions import SearxParameterException
@@ -10,7 +13,7 @@ from searx.utils import detect_language
# remove duplicate queries.
-# FIXME: does not fix "!music !soundcloud", because the categories are 'none' and 'music'
+# HINT: does not fix "!music !soundcloud", because the categories are 'none' and 'music'
def deduplicate_engineref_list(engineref_list: List[EngineRef]) -> List[EngineRef]:
engineref_dict = {q.category + '|' + q.name: q for q in engineref_list}
return list(engineref_dict.values())
@@ -55,7 +58,7 @@ def parse_lang(preferences: Preferences, form: Dict[str, str], raw_text_query: R
return preferences.get_value('language')
# get language
# set specific language if set on request, query or preferences
- # TODO support search with multiple languages
+ # search with multiple languages is not supported (by most engines)
if len(raw_text_query.languages):
query_lang = raw_text_query.languages[-1]
elif 'language' in form:
@@ -153,7 +156,10 @@ def get_selected_categories(preferences: Preferences, form: Optional[Dict[str, s
return selected_categories
-def get_engineref_from_category_list(category_list: List[str], disabled_engines: List[str]) -> List[EngineRef]:
+def get_engineref_from_category_list( # pylint: disable=invalid-name
+ category_list: List[str],
+ disabled_engines: List[str],
+) -> List[EngineRef]:
result = []
for categ in category_list:
result.extend(
@@ -172,7 +178,7 @@ def parse_generic(preferences: Preferences, form: Dict[str, str], disabled_engin
explicit_engine_list = False
if not is_locked('categories'):
# parse the form only if the categories are not locked
- for pd_name, pd in form.items():
+ for pd_name, pd in form.items(): # pylint: disable=invalid-name
if pd_name == 'engines':
pd_engines = [
EngineRef(engine_name, engines[engine_name].categories[0])
diff --git a/searx/webapp.py b/searx/webapp.py
index c64ef0fc0..a6cadcf6c 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
-# pyright: basic
"""WebbApp
"""
diff --git a/searx/webutils.py b/searx/webutils.py
index 8cdcab84b..c58b981f6 100644
--- a/searx/webutils.py
+++ b/searx/webutils.py
@@ -1,4 +1,6 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
+
from __future__ import annotations
import os
@@ -108,7 +110,7 @@ class CSVWriter:
self.writerow(row)
-def write_csv_response(csv: CSVWriter, rc: ResultContainer) -> None:
+def write_csv_response(csv: CSVWriter, rc: ResultContainer) -> None: # pylint: disable=redefined-outer-name
"""Write rows of the results to a query (``application/csv``) into a CSV
table (:py:obj:`CSVWriter`). First line in the table contain the column
names. The column "type" specifies the type, the following types are
@@ -143,7 +145,7 @@ def write_csv_response(csv: CSVWriter, rc: ResultContainer) -> None:
csv.writerow([row.get(key, '') for key in keys])
-class JSONEncoder(json.JSONEncoder):
+class JSONEncoder(json.JSONEncoder): # pylint: disable=missing-class-docstring
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
@@ -226,8 +228,7 @@ def prettify_url(url, max_length=74):
if len(url) > max_length:
chunk_len = int(max_length / 2 + 1)
return '{0}[...]{1}'.format(url[:chunk_len], url[-chunk_len:])
- else:
- return url
+ return url
def contains_cjko(s: str) -> bool:
@@ -269,8 +270,7 @@ def regex_highlight_cjk(word: str) -> str:
rword = re.escape(word)
if contains_cjko(rword):
return fr'({rword})'
- else:
- return fr'\b({rword})(?!\w)'
+ return fr'\b({rword})(?!\w)'
def highlight_content(content, query):
@@ -279,7 +279,6 @@ def highlight_content(content, query):
return None
# ignoring html contents
- # TODO better html content detection
if content.find('<') != -1:
return content
@@ -353,8 +352,8 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[
sorted_groups = sorted(((name, list(engines)) for name, engines in subgroups), key=group_sort_key)
ret_val = []
- for groupname, engines in sorted_groups:
+ for groupname, _engines in sorted_groups:
group_bang = '!' + groupname.replace(' ', '_') if groupname != NO_SUBGROUPING else ''
- ret_val.append((groupname, group_bang, sorted(engines, key=engine_sort_key)))
+ ret_val.append((groupname, group_bang, sorted(_engines, key=engine_sort_key)))
return ret_val