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
[mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION
Markus Heiser542f7d0d7bd1
diff --git a/.pylintrc b/.pylintrcindex a5b00227e..e4c51215d 100644--- a/.pylintrc+++ b/.pylintrc@@ -27,7 +27,7 @@ ignore-patterns=#init-hook=# Use multiple processes to speed up Pylint.-jobs=1+jobs=0# List of plugins (as comma separated values of python modules names) to load,# usually to register additional checkers.diff --git a/docs/conf.py b/docs/conf.pyindex 2ed85a800..fec9eb64b 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# SPDX-License-Identifier: AGPL-3.0-or-laterimport sys, osdiff --git a/examples/basic_engine.py b/examples/basic_engine.pydeleted file mode 100644index c7d02afa6..000000000--- a/examples/basic_engine.py+++ /dev/null@@ -1,25 +0,0 @@--categories = ['general'] # optional---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- '''-- params['url'] = 'https://host/%s' % query-- return params---def response(resp):- '''post-response callback- resp: requests response object- '''- return [{'url': '', 'title': '', 'content': ''}]diff --git a/manage b/manageindex 9871906d2..33e2808e1 100755--- a/manage+++ b/manage@@ -52,23 +52,6 @@ if [ -S "${_dev_redis_sock}" ] && [ -z "${SEARXNG_REDIS_URL}" ]; thenexport SEARXNG_REDIS_URL="unix://${_dev_redis_sock}?db=0"fi-pylint.FILES() {-- # List files tagged by comment:- #- # # lint: pylint- #- # These py files are linted by test.pylint()-- grep -l -r --include \*.py '^#[[:blank:]]*lint:[[:blank:]]*pylint' searx searxng_extra tests- find . -name searxng.msg-}--PYLINT_FILES=()-while IFS= read -r line; do- PYLINT_FILES+=("$line")-done <<< "$(pylint.FILES)"-YAMLLINT_FILES=()while IFS= read -r line; doYAMLLINT_FILES+=("$line")@@ -78,10 +61,6 @@ RST_FILES=('README.rst')-PYLINT_SEARXNG_DISABLE_OPTION="\-I,C,R,\-W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401,\-E1136"help() {nvm.helpcat <<EOFdiff --git a/searx/__init__.py b/searx/__init__.pyindex 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-importimport sysimport osdiff --git a/searx/answerers/__init__.py b/searx/answerers/__init__.pyindex 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 sysfrom os import listdirfrom os.path import realpath, dirname, join, isdir-from searx.utils import load_modulefrom collections import defaultdict+from searx.utils import load_moduleanswerers_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('_'):continuemodule = 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-nameby_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.pyindex 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 hashlibimport randomimport stringdiff --git a/searx/answerers/statistics/answerer.py b/searx/answerers/statistics/answerer.pyindex 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-laterfrom functools import reducefrom operator import muldiff --git a/searx/autocomplete.py b/searx/autocomplete.pyindex 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.pyindex 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 toextract messages from:diff --git a/searx/botdetection/__init__.py b/searx/botdetection/__init__.pyindex 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.pyindex 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-namefrom __future__ import annotationsdiff --git a/searx/botdetection/config.py b/searx/botdetection/config.pyindex 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 validationand deprecated names.diff --git a/searx/botdetection/http_accept.py b/searx/botdetection/http_accept.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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__.pyindex 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.alldiff --git a/searx/enginelib/__init__.py b/searx/enginelib/__init__.pyindex 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.pyindex 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 filein the *data folder*. Most often traits are languages and region codes andtheir 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: ignoretraits = self.copy()diff --git a/searx/engines/bandcamp.py b/searx/engines/bandcamp.pyindex 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.pyindex 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={odef 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'] - 1if 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.pyindex 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 stilldiff --git a/searx/exceptions.py b/searx/exceptions.pyindex 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.pyindex 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-docstringfrom urllib.parse import quote_plus, urlparsefrom 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-nameif external_bangs_db is None:external_bangs_db = EXTERNAL_BANGSdiff --git a/searx/external_urls.py b/searx/external_urls.pyindex 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 mathfrom 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_templatereturn Nonediff --git a/searx/flaskfix.py b/searx/flaskfix.pyindex 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-docstringfrom urllib.parse import urlparsediff --git a/searx/infopage/__init__.py b/searx/infopage/__init__.pyindex 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.pyindex 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 tolimit suspicious requests from an IP. The motivation behind this is the factthat SearXNG passes through requests from bots and is thus classified as a botdiff --git a/searx/locales.py b/searx/locales.pyindex 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__.pyindex 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-docstringimport typingdiff --git a/searx/metrics/error_recorder.py b/searx/metrics/error_recorder.pyindex 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 typingimport inspectfrom json import JSONDecodeError@@ -16,7 +19,7 @@ from searx.engines import engineserrors_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 = filenameself.function = functionself.line_no = line_no@@ -39,7 +44,7 @@ class ErrorContext:self.log_parameters = log_parametersself.secondary = secondary- def __eq__(self, o) -> bool:+ def __eq__(self, o) -> bool: # pylint: disable=invalid-nameif not isinstance(o, ErrorContext):return Falsereturn (@@ -109,7 +114,7 @@ def get_request_exception_messages(status_code = Nonereason = Nonehostname = 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-statementsif isinstance(exc, JSONDecodeError):return (exc.msg,)if isinstance(exc, TypeError):diff --git a/searx/metrics/models.py b/searx/metrics/models.pyindex 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-docstringimport decimalimport 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 ignoredq = 0if q >= self._size:- """Value above the maximum is replaced by the maximum"""+ # Value above the maximum is replaced by the maximumq = self._size - 1with 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@propertydef 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@propertydef 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-nameif yp != 0:result[round(float(x), width_exponent)] = ypx += 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-namefor 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-namelogger.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-docstringdef observe(self, value):pass-class VoidCounterStorage(CounterStorage):+class VoidCounterStorage(CounterStorage): # pylint: disable=missing-class-docstringdef add(self, value, *args):passdiff --git a/searx/network/__init__.py b/searx/network/__init__.pyindex 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-statementimport asynciodiff --git a/searx/network/client.py b/searx/network/client.pyindex 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-statementimport asynciodiff --git a/searx/network/network.py b/searx/network/network.pyindex 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-docstringdiff --git a/searx/network/raise_for_httperror.py b/searx/network/raise_for_httperror.pyindex 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__.pyindex 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-docstringimport sysdiff --git a/searx/plugins/ahmia_filter.py b/searx/plugins/ahmia_filter.pyindex 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-docstringfrom hashlib import md5from 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 Trueresult_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-statementif not settings['outgoing']['using_tor_proxy']:# disable the plugindiff --git a/searx/plugins/hash_plugin.py b/searx/plugins/hash_plugin.pyindex 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, <[email protected]>-(C) 2018, 2020 by Vaclav Zouzalik-'''--from flask_babel import gettextimport hashlibimport 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 pageif search.search_query.pageno > 1:return True@@ -40,7 +26,7 @@ def post_search(request, search):return Truefunction, string = m.groups()- if string.strip().__len__() == 0:+ if not string.strip():# end if the string is emptyreturn Truediff --git a/searx/plugins/hostname_replace.py b/searx/plugins/hostname_replace.pyindex 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-docstringimport refrom urllib.parse import urlunparse, urlparse++from flask_babel import gettext+from searx import settingsfrom searx.plugins import logger-from flask_babel import gettextname = 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.pyindex 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 refrom urllib.parse import urlparse, parse_qsl+from flask_babel import gettext-import refrom 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 Truediff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.pyindex 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-nameimport rediff --git a/searx/plugins/tor_check.py b/searx/plugins/tor_check.pyindex 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 theuser searches for ``tor-check``. It fetches the tor exit node list fromhttps://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.pyindex 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, <[email protected]>-'''--from flask_babel import gettextimport refrom 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 = Truepreference_section = 'privacy'-def on_result(request, search, result):+def on_result(_request, _search, result):if 'parsed_url' not in result:return Truediff --git a/searx/preferences.py b/searx/preferences.pyindex 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.pyindex 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-docstringfrom abc import abstractmethod, ABCimport 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-getvalue = engine_shortcuts[value]# check if prefix is equal with engine namediff --git a/searx/redisdb.py b/searx/redisdb.pyindex 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-pydiff --git a/searx/redislib.py b/searx/redislib.pyindex 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.pyindex 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 refrom collections import defaultdictfrom 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 0def 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 weightsif 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-docstringengine: strtotal: floatload: float-class UnresponsiveEngine(NamedTuple):+class UnresponsiveEngine(NamedTuple): # pylint: disable=missing-class-docstringengine: strerror_type: strsuspended: bool@@ -189,7 +191,7 @@ class ResultContainer:self.on_result = lambda _: Trueself._lock = RLock()- def extend(self, engine_name, results):+ def extend(self, engine_name, results): # pylint: disable=too-many-branchesif self._closed:return@@ -314,11 +316,11 @@ class ResultContainer:if result_template != 'images.html':# not an image, same template, same url : it's a duplicatereturn 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_resultreturn Nonedef __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-itemsv = categoryPositions[k]['index']if v >= index:categoryPositions[k]['index'] = v + 1diff --git a/searx/search/__init__.py b/searx/search/__init__.pyindex 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-methodsimport threadingdiff --git a/searx/search/checker/__init__.py b/searx/search/checker/__init__.pyindex 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-docstringfrom .impl import Checkerfrom .background import initialize, get_resultdiff --git a/searx/search/checker/__main__.py b/searx/search/checker/__main__.pyindex 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-docstringimport sysdiff --git a/searx/search/checker/background.py b/searx/search/checker/background.pyindex 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-importimport jsonimport timediff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.pyindex 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-nameimport gcimport 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 Nonedef _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.pyindex 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.pyindex 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-docstringimport typingimport 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-argumentsself.query = queryself.engineref_list = engineref_listself.lang = langdiff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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.pyindex 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-branchesfrom typing import Optionalfrom os import environdiff --git a/searx/sxng_locales.py b/searx/sxng_locales.pyindex 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.pyindex 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 namediff --git a/searx/utils.py b/searx/utils.pyindex 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: ignoreglobal _FASTTEXT_MODEL # pylint: disable=global-statementif _FASTTEXT_MODEL is None:import fasttext # pylint: disable=import-outside-topleveldiff --git a/searx/version.py b/searx/version.pyindex 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-docstringimport 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.pyVERSION_STRING = "{VERSION_STRING}"diff --git a/searx/webadapter.py b/searx/webadapter.pyindex 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 defaultdictfrom typing import Dict, List, Optional, Tuplefrom 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: Rreturn 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, sreturn 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_enginexplicit_engine_list = Falseif 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-nameif pd_name == 'engines':pd_engines = [EngineRef(engine_name, engines[engine_name].categories[0])diff --git a/searx/webapp.py b/searx/webapp.pyindex 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.pyindex 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 annotationsimport 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 CSVtable (:py:obj:`CSVWriter`). First line in the table contain the columnnames. 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-docstringdef 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 urldef 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 detectionif 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_valdiff --git a/searxng_extra/__init__.py b/searxng_extra/__init__.pyindex e69de29bb..9ed59c825 100644--- a/searxng_extra/__init__.py+++ b/searxng_extra/__init__.py@@ -0,0 +1,2 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringdiff --git a/searxng_extra/docs_prebuild b/searxng_extra/docs_prebuildindex f19d59800..9e4a18524 100755--- a/searxng_extra/docs_prebuild+++ b/searxng_extra/docs_prebuild@@ -1,7 +1,5 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later-"""Script that implements some prebuild tasks needed by target docs.prebuild"""@@ -9,10 +7,10 @@ import sysimport os.pathimport timefrom contextlib import contextmanager+from searx import settings, get_setting, localesfrom searx.infopage import InfoPageSet, InfoPage-_doc_user = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'docs', 'user'))@@ -27,13 +25,13 @@ def main():with infopageset_ctx as infopageset:for _, _, page in infopageset.iter_pages('en'):fname = os.path.join(_doc_user, os.path.basename(page.fname))- with open(fname, 'w') as f:+ with open(fname, 'w', encoding='utf-8') as f:f.write(page.content)-class OfflinePage(InfoPage):+class OfflinePage(InfoPage): # pylint: disable=missing-class-docstring- def get_ctx(self): # pylint: disable=no-self-use+ def get_ctx(self):"""Jinja context to render :py:obj:`DocPage.content` for offline purpose (nolinks to SearXNG instance)"""@@ -55,7 +53,7 @@ def _instance_infosetset_ctx(base_url):# registered in the Flask app.settings['server']['secret_key'] = ''- from searx.webapp import app+ from searx.webapp import app # pylint: disable=import-outside-toplevel# Specify base_url so that url_for() works for base_urls. If base_url is# specified, then these values from are given preference over any Flask'sdiff --git a/searxng_extra/standalone_searx.py b/searxng_extra/standalone_searx.pyindex 2ce9925c5..cf053d7ee 100755--- a/searxng_extra/standalone_searx.py+++ b/searxng_extra/standalone_searx.py@@ -1,8 +1,5 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later-# (C) Copyright Contributors to the SearXNG project.-"""Script to run SearXNG from terminal.DON'T USE THIS SCRIPT!!diff --git a/searxng_extra/update/__init__.py b/searxng_extra/update/__init__.pyindex e69de29bb..9ed59c825 100644--- a/searxng_extra/update/__init__.py+++ b/searxng_extra/update/__init__.py@@ -0,0 +1,2 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringdiff --git a/searxng_extra/update/update_ahmia_blacklist.py b/searxng_extra/update/update_ahmia_blacklist.pyindex 8bee4a808..c890b3760 100755--- a/searxng_extra/update/update_ahmia_blacklist.py+++ b/searxng_extra/update/update_ahmia_blacklist.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""This script saves `Ahmia's blacklist`_ for onion sites.diff --git a/searxng_extra/update/update_currencies.py b/searxng_extra/update/update_currencies.pyindex a949c4696..dcfa6e7a2 100755--- a/searxng_extra/update/update_currencies.py+++ b/searxng_extra/update/update_currencies.py@@ -1,7 +1,5 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later-"""Fetch currencies from :origin:`searx/engines/wikidata.py` engine.Output file: :origin:`searx/data/currencies.json` (:origin:`CI Update data ...diff --git a/searxng_extra/update/update_engine_descriptions.py b/searxng_extra/update/update_engine_descriptions.pyindex fc793ea2f..916e18802 100755--- a/searxng_extra/update/update_engine_descriptions.py+++ b/searxng_extra/update/update_engine_descriptions.py@@ -1,7 +1,5 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later-"""Fetch website description from websites and from:origin:`searx/engines/wikidata.py` engine.diff --git a/searxng_extra/update/update_engine_traits.py b/searxng_extra/update/update_engine_traits.pyindex eb4484f62..ef5dc607c 100755--- a/searxng_extra/update/update_engine_traits.py+++ b/searxng_extra/update/update_engine_traits.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Update :py:obj:`searx.enginelib.traits.EngineTraitsMap` and :origin:`searx/languages.py`@@ -28,7 +27,7 @@ from searx.enginelib.traits import EngineTraitsMap# Output files.languages_file = Path(searx_dir) / 'sxng_locales.py'languages_file_header = """\-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later'''List of SearXNG's locale codes... hint::diff --git a/searxng_extra/update/update_external_bangs.py b/searxng_extra/update/update_external_bangs.pyindex 9896d1d7d..1d367a887 100755--- a/searxng_extra/update/update_external_bangs.py+++ b/searxng_extra/update/update_external_bangs.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Update :origin:`searx/data/external_bangs.json` using the duckduckgo bangsfrom :py:obj:`BANGS_URL`.diff --git a/searxng_extra/update/update_firefox_version.py b/searxng_extra/update/update_firefox_version.pyindex ad6d9b842..451530ca8 100755--- a/searxng_extra/update/update_firefox_version.py+++ b/searxng_extra/update/update_firefox_version.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Fetch firefox useragent signaturesdiff --git a/searxng_extra/update/update_locales.py b/searxng_extra/update/update_locales.pyindex 4b8f6222c..04abaecda 100755--- a/searxng_extra/update/update_locales.py+++ b/searxng_extra/update/update_locales.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Update locale names in :origin:`searx/data/locales.json` used by:ref:`searx.locales`diff --git a/searxng_extra/update/update_osm_keys_tags.py b/searxng_extra/update/update_osm_keys_tags.pyindex d350756ec..2c4f5897f 100755--- a/searxng_extra/update/update_osm_keys_tags.py+++ b/searxng_extra/update/update_osm_keys_tags.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Fetch OSM keys and tags.diff --git a/searxng_extra/update/update_pygments.py b/searxng_extra/update/update_pygments.pyindex 5d11b28dc..7c043af7b 100755--- a/searxng_extra/update/update_pygments.py+++ b/searxng_extra/update/update_pygments.py@@ -1,5 +1,4 @@#!/usr/bin/env python-# lint: pylint# SPDX-License-Identifier: AGPL-3.0-or-later"""Update pygments stylediff --git a/searxng_extra/update/update_wikidata_units.py b/searxng_extra/update/update_wikidata_units.pyindex 6a7ceb1b8..a1a3731fc 100755--- a/searxng_extra/update/update_wikidata_units.py+++ b/searxng_extra/update/update_wikidata_units.py@@ -1,8 +1,5 @@#!/usr/bin/env python# SPDX-License-Identifier: AGPL-3.0-or-later-# lint: pylint-# pylint: disable=missing-module-docstring-"""Fetch units from :origin:`searx/engines/wikidata.py` engine.Output file: :origin:`searx/data/wikidata_units.json` (:origin:`CI Update datadiff --git a/setup.py b/setup.pyindex cf77e1a21..30b933a49 100644--- a/setup.py+++ b/setup.py@@ -1,4 +1,4 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later"""Installer for SearXNG package."""from setuptools import setup, find_packagesdiff --git a/tests/__init__.py b/tests/__init__.pyindex 8399f0604..2ccc51847 100644--- a/tests/__init__.py+++ b/tests/__init__.py@@ -1,5 +1,7 @@-import os+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+import osimport aiounittestos.environ.pop('SEARX_DEBUG', None)diff --git a/tests/robot/__init__.py b/tests/robot/__init__.pyindex e69de29bb..f7378de06 100644--- a/tests/robot/__init__.py+++ b/tests/robot/__init__.py@@ -0,0 +1,2 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring, cyclic-importdiff --git a/tests/robot/__main__.py b/tests/robot/__main__.pyindex 758a521ee..20b15ef04 100644--- a/tests/robot/__main__.py+++ b/tests/robot/__main__.py@@ -1,5 +1,4 @@# SPDX-License-Identifier: AGPL-3.0-or-later-# lint: pylint"""Shared testing code."""# pylint: disable=missing-function-docstringdiff --git a/tests/robot/test_webapp.py b/tests/robot/test_webapp.pyindex 42066e37a..fecbf53f0 100644--- a/tests/robot/test_webapp.py+++ b/tests/robot/test_webapp.py@@ -1,5 +1,4 @@# SPDX-License-Identifier: AGPL-3.0-or-later-# lint: pylint# pylint: disable=missing-module-docstring,missing-function-docstringfrom time import sleepdiff --git a/tests/unit/__init__.py b/tests/unit/__init__.pyindex 9094e836a..e43c93f1c 100644--- a/tests/unit/__init__.py+++ b/tests/unit/__init__.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+import osfrom os.path import dirname, sep, abspathdiff --git a/tests/unit/engines/test_command.py b/tests/unit/engines/test_command.pyindex fa29c4e3f..a7d2d2d56 100644--- a/tests/unit/engines/test_command.py+++ b/tests/unit/engines/test_command.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+'''searx is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License as published bydiff --git a/tests/unit/engines/test_xpath.py b/tests/unit/engines/test_xpath.pyindex e616ff025..24f14127b 100644--- a/tests/unit/engines/test_xpath.py+++ b/tests/unit/engines/test_xpath.py@@ -1,4 +1,6 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+from collections import defaultdictimport mockfrom searx.engines import xpathdiff --git a/tests/unit/network/__init__.py b/tests/unit/network/__init__.pyindex e69de29bb..9ed59c825 100644--- a/tests/unit/network/__init__.py+++ b/tests/unit/network/__init__.py@@ -0,0 +1,2 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringdiff --git a/tests/unit/network/test_network.py b/tests/unit/network/test_network.pyindex 905b981c1..eabb23082 100644--- a/tests/unit/network/test_network.py+++ b/tests/unit/network/test_network.py@@ -1,4 +1,5 @@# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring, protected-accessfrom mock import patch@@ -8,7 +9,7 @@ from searx.network.network import Network, NETWORKS, initializefrom tests import SearxTestCase-class TestNetwork(SearxTestCase):+class TestNetwork(SearxTestCase): # pylint: disable=missing-class-docstringdef setUp(self):initialize()@@ -121,7 +122,7 @@ class TestNetwork(SearxTestCase):await network.aclose()-class TestNetworkRequestRetries(SearxTestCase):+class TestNetworkRequestRetries(SearxTestCase): # pylint: disable=missing-class-docstringTEXT = 'Lorem Ipsum'@@ -129,7 +130,7 @@ class TestNetworkRequestRetries(SearxTestCase):def get_response_404_then_200(cls):first = True- async def get_response(*args, **kwargs):+ async def get_response(*args, **kwargs): # pylint: disable=unused-argumentnonlocal firstif first:first = False@@ -169,7 +170,7 @@ class TestNetworkRequestRetries(SearxTestCase):async def test_retries_exception_then_200(self):request_count = 0- async def get_response(*args, **kwargs):+ async def get_response(*args, **kwargs): # pylint: disable=unused-argumentnonlocal request_countrequest_count += 1if request_count < 3:@@ -194,7 +195,7 @@ class TestNetworkRequestRetries(SearxTestCase):await network.aclose()-class TestNetworkStreamRetries(SearxTestCase):+class TestNetworkStreamRetries(SearxTestCase): # pylint: disable=missing-class-docstringTEXT = 'Lorem Ipsum'@@ -202,7 +203,7 @@ class TestNetworkStreamRetries(SearxTestCase):def get_response_exception_then_200(cls):first = True- def stream(*args, **kwargs):+ def stream(*args, **kwargs): # pylint: disable=unused-argumentnonlocal firstif first:first = False@@ -228,7 +229,7 @@ class TestNetworkStreamRetries(SearxTestCase):async def test_retries_exception(self):first = True- def stream(*args, **kwargs):+ def stream(*args, **kwargs): # pylint: disable=unused-argumentnonlocal firstif first:first = Falsediff --git a/tests/unit/test_answerers.py b/tests/unit/test_answerers.pyindex 73148f327..e96e20c3c 100644--- a/tests/unit/test_answerers.py+++ b/tests/unit/test_answerers.py@@ -1,4 +1,5 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringfrom mock import Mock@@ -6,7 +7,7 @@ from searx.answerers import answerersfrom tests import SearxTestCase-class AnswererTest(SearxTestCase):+class AnswererTest(SearxTestCase): # pylint: disable=missing-class-docstringdef test_unicode_input(self):query = Mock()unicode_payload = 'árvíztűrő tükörfúrógép'diff --git a/tests/unit/test_engines_init.py b/tests/unit/test_engines_init.pyindex 2844569d1..4872a1b1b 100644--- a/tests/unit/test_engines_init.py+++ b/tests/unit/test_engines_init.py@@ -1,8 +1,11 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+from searx import settings, enginesfrom tests import SearxTestCase-class TestEnginesInit(SearxTestCase):+class TestEnginesInit(SearxTestCase): # pylint: disable=missing-class-docstring@classmethoddef tearDownClass(cls):settings['outgoing']['using_tor_proxy'] = False@@ -19,7 +22,7 @@ class TestEnginesInit(SearxTestCase):self.assertIn('engine1', engines.engines)self.assertIn('engine2', engines.engines)- def test_initialize_engines_exclude_onions(self):+ def test_initialize_engines_exclude_onions(self): # pylint: disable=invalid-namesettings['outgoing']['using_tor_proxy'] = Falseengine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1', 'categories': 'general'},@@ -31,7 +34,7 @@ class TestEnginesInit(SearxTestCase):self.assertIn('engine1', engines.engines)self.assertNotIn('onions', engines.categories)- def test_initialize_engines_include_onions(self):+ def test_initialize_engines_include_onions(self): # pylint: disable=invalid-namesettings['outgoing']['using_tor_proxy'] = Truesettings['outgoing']['extra_proxy_timeout'] = 100.0engine_list = [@@ -59,7 +62,7 @@ class TestEnginesInit(SearxTestCase):engine_list = [{'engine': 'dummy', 'shortcut': 'e1', 'categories': 'general'},]- with self.assertLogs('searx.engines', level='ERROR') as cm:+ with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-nameengines.load_engines(engine_list)self.assertEqual(len(engines.engines), 0)self.assertEqual(cm.output, ['ERROR:searx.engines:An engine does not have a "name" field'])@@ -69,7 +72,7 @@ class TestEnginesInit(SearxTestCase):engine_list = [{'name': 'engine2', 'shortcut': 'e2', 'categories': 'onions'},]- with self.assertLogs('searx.engines', level='ERROR') as cm:+ with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-nameengines.load_engines(engine_list)self.assertEqual(len(engines.engines), 0)self.assertEqual(diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.pyindex 13d004322..514b9ce1f 100644--- a/tests/unit/test_exceptions.py+++ b/tests/unit/test_exceptions.py@@ -1,11 +1,12 @@# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringfrom tests import SearxTestCaseimport searx.exceptionsfrom searx import get_setting-class TestExceptions(SearxTestCase):+class TestExceptions(SearxTestCase): # pylint: disable=missing-class-docstringdef test_default_suspend_time(self):with self.assertRaises(searx.exceptions.SearxEngineAccessDeniedException) as e:raise searx.exceptions.SearxEngineAccessDeniedException()diff --git a/tests/unit/test_external_bangs.py b/tests/unit/test_external_bangs.pyindex 794edf159..ad20d52f7 100644--- a/tests/unit/test_external_bangs.py+++ b/tests/unit/test_external_bangs.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+from searx.external_bang import (get_node,resolve_bang_definition,@@ -31,9 +34,9 @@ TEST_DB = {}-class TestGetNode(SearxTestCase):+class TestGetNode(SearxTestCase): # pylint: disable=missing-class-docstring- DB = {+ DB = { # pylint:disable=invalid-name'trie': {'exam': {'ple': 'test',@@ -62,7 +65,7 @@ class TestGetNode(SearxTestCase):self.assertEqual(after, 's')-class TestResolveBangDefinition(SearxTestCase):+class TestResolveBangDefinition(SearxTestCase): # pylint:disable=missing-class-docstringdef test_https(self):url, rank = resolve_bang_definition('//example.com/' + chr(2) + chr(1) + '42', 'query')self.assertEqual(url, 'https://example.com/query')@@ -74,7 +77,7 @@ class TestResolveBangDefinition(SearxTestCase):self.assertEqual(rank, 0)-class TestGetBangDefinitionAndAutocomplete(SearxTestCase):+class TestGetBangDefinitionAndAutocomplete(SearxTestCase): # pylint:disable=missing-class-docstringdef test_found(self):bang_definition, new_autocomplete = get_bang_definition_and_autocomplete('exam', external_bangs_db=TEST_DB)self.assertEqual(bang_definition, TEST_DB['trie']['exam'][LEAF_KEY])@@ -106,7 +109,7 @@ class TestGetBangDefinitionAndAutocomplete(SearxTestCase):self.assertEqual(new_autocomplete, [])-class TestExternalBangJson(SearxTestCase):+class TestExternalBangJson(SearxTestCase): # pylint:disable=missing-class-docstringdef test_no_external_bang_query(self):result = get_bang_url(SearchQuery('test', engineref_list=[EngineRef('wikipedia', 'general')]))self.assertEqual(result, None)diff --git a/tests/unit/test_locales.py b/tests/unit/test_locales.pyindex e18353145..6407a5761 100644--- a/tests/unit/test_locales.py+++ b/tests/unit/test_locales.py@@ -1,6 +1,5 @@-# -*- coding: utf-8 -*-# SPDX-License-Identifier: AGPL-3.0-or-later-# lint: pylint+# pylint: disable=missing-module-docstring"""Test some code from module :py:obj:`searx.locales`"""from searx import localesdiff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.pyindex 90436266e..a5a2f0471 100644--- a/tests/unit/test_plugins.py+++ b/tests/unit/test_plugins.py@@ -1,4 +1,7 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring++from mock import Mockfrom searx import (plugins,@@ -6,21 +9,20 @@ from searx import (botdetection,)-from mock import Mockfrom tests import SearxTestCasedef get_search_mock(query, **kwargs):- return Mock(search_query=Mock(query=query, **kwargs), result_container=Mock(answers=dict()))+ return Mock(search_query=Mock(query=query, **kwargs), result_container=Mock(answers={}))-class PluginMock:+class PluginMock: # pylint: disable=missing-class-docstring, too-few-public-methodsdefault_on = Falsename = 'Default plugin'description = 'Default plugin description'-class PluginStoreTest(SearxTestCase):+class PluginStoreTest(SearxTestCase): # pylint: disable=missing-class-docstringdef test_PluginStore_init(self):store = plugins.PluginStore()self.assertTrue(isinstance(store.plugins, list) and len(store.plugins) == 0)@@ -46,7 +48,7 @@ class PluginStoreTest(SearxTestCase):self.assertTrue(testplugin.asdf.called) # pylint: disable=E1101-class SelfIPTest(SearxTestCase):+class SelfIPTest(SearxTestCase): # pylint: disable=missing-class-docstringdef test_PluginStore_init(self):plugin = plugins.load_and_initialize_plugin('searx.plugins.self_info', False, (None, {}))store = plugins.PluginStore()@@ -99,7 +101,7 @@ class SelfIPTest(SearxTestCase):self.assertFalse('user-agent' in search.result_container.answers)-class HashPluginTest(SearxTestCase):+class HashPluginTest(SearxTestCase): # pylint: disable=missing-class-docstringdef test_PluginStore_init(self):store = plugins.PluginStore()plugin = plugins.load_and_initialize_plugin('searx.plugins.hash_plugin', False, (None, {}))diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.pyindex a33c78a44..5855c12a6 100644--- a/tests/unit/test_preferences.py+++ b/tests/unit/test_preferences.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring, invalid-name+from searx.locales import locales_initializefrom searx.preferences import (EnumStringSetting,@@ -12,13 +15,13 @@ from tests import SearxTestCaselocales_initialize()-class PluginStub:+class PluginStub: # pylint: disable=missing-class-docstring, too-few-public-methodsdef __init__(self, plugin_id, default_on):self.id = plugin_idself.default_on = default_on-class TestSettings(SearxTestCase):+class TestSettings(SearxTestCase): # pylint: disable=missing-class-docstring# map settingsdef test_map_setting_invalid_default_value(self):@@ -118,9 +121,9 @@ class TestSettings(SearxTestCase):self.assertEqual(set(setting.get_enabled()), set(['plugin1', 'plugin3']))-class TestPreferences(SearxTestCase):+class TestPreferences(SearxTestCase): # pylint: disable=missing-class-docstringdef test_encode(self):- from searx.preferences import Preferences+ from searx.preferences import Preferences # pylint: disable=import-outside-toplevelpref = Preferences(['simple'], ['general'], {}, [])url_params = (diff --git a/tests/unit/test_query.py b/tests/unit/test_query.pyindex 59bbd6574..b4f5f8a0d 100644--- a/tests/unit/test_query.py+++ b/tests/unit/test_query.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+from searx import settingsfrom searx.engines import load_enginesfrom searx.query import RawTextQuery@@ -16,7 +19,7 @@ TEST_ENGINES = []-class TestQuery(SearxTestCase):+class TestQuery(SearxTestCase): # pylint:disable=missing-class-docstringdef test_simple_query(self):query_text = 'the query'query = RawTextQuery(query_text, [])@@ -56,7 +59,7 @@ class TestQuery(SearxTestCase):self.assertEqual(query.getFullQuery(), '<8 another text')-class TestLanguageParser(SearxTestCase):+class TestLanguageParser(SearxTestCase): # pylint:disable=missing-class-docstringdef test_language_code(self):language = 'es-ES'query_text = 'the query'@@ -144,7 +147,7 @@ class TestLanguageParser(SearxTestCase):self.assertEqual(query.autocomplete_list, [':zh-cn', ':zh-hk', ':zh-tw'])-class TestTimeoutParser(SearxTestCase):+class TestTimeoutParser(SearxTestCase): # pylint:disable=missing-class-docstringdef test_timeout_below100(self):query_text = '<3 the query'query = RawTextQuery(query_text, [])@@ -196,7 +199,7 @@ class TestTimeoutParser(SearxTestCase):self.assertEqual(query.autocomplete_list, ['<3', '<850'])-class TestExternalBangParser(SearxTestCase):+class TestExternalBangParser(SearxTestCase): # pylint:disable=missing-class-docstringdef test_external_bang(self):query_text = '!!ddg the query'query = RawTextQuery(query_text, [])@@ -226,7 +229,7 @@ class TestExternalBangParser(SearxTestCase):self.assertEqual(query.get_autocomplete_full_query(a), a + ' the query')-class TestBang(SearxTestCase):+class TestBang(SearxTestCase): # pylint:disable=missing-class-docstringSPECIFIC_BANGS = ['!dummy_engine', '!du', '!general']THE_QUERY = 'the query'diff --git a/tests/unit/test_results.py b/tests/unit/test_results.pyindex 113e9cd3c..72486bbc7 100644--- a/tests/unit/test_results.py+++ b/tests/unit/test_results.py@@ -1,4 +1,5 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringfrom searx.results import ResultContainerfrom tests import SearxTestCase@@ -17,8 +18,7 @@ def fake_result(url='https://aa.bb/cc?dd=ee#ff', title='aaa', content='bbb', engreturn result-# TODO-class ResultContainerTestCase(SearxTestCase):+class ResultContainerTestCase(SearxTestCase): # pylint: disable=missing-class-docstringdef test_empty(self):c = ResultContainer()self.assertEqual(c.get_ordered_results(), [])diff --git a/tests/unit/test_search.py b/tests/unit/test_search.pyindex 87f5f280b..b85c90c68 100644--- a/tests/unit/test_search.py+++ b/tests/unit/test_search.py@@ -1,4 +1,5 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring, invalid-namefrom copy import copy@@ -23,7 +24,7 @@ TEST_ENGINES = []-class SearchQueryTestCase(SearxTestCase):+class SearchQueryTestCase(SearxTestCase): # pylint: disable=missing-class-docstringdef test_repr(self):s = SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, '1', 5.0, 'g')self.assertEqual(@@ -42,10 +43,10 @@ class SearchQueryTestCase(SearxTestCase):self.assertEqual(s, t)-class SearchTestCase(SearxTestCase):+class SearchTestCase(SearxTestCase): # pylint: disable=missing-class-docstringdef setUp(self):- from searx import webapp # pylint disable=import-outside-toplevel+ from searx import webapp # pylint: disable=import-outside-toplevelself.app = webapp.appdiff --git a/tests/unit/test_settings_loader.py b/tests/unit/test_settings_loader.pyindex 2330e8460..088767597 100644--- a/tests/unit/test_settings_loader.py+++ b/tests/unit/test_settings_loader.py@@ -1,4 +1,5 @@# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringfrom os.path import dirname, join, abspathfrom unittest.mock import patch@@ -11,7 +12,7 @@ from tests import SearxTestCasetest_dir = abspath(dirname(__file__))-class TestLoad(SearxTestCase):+class TestLoad(SearxTestCase): # pylint: disable=missing-class-docstringdef test_load_zero(self):with self.assertRaises(SearxSettingsException):settings_loader.load_yaml('/dev/zero')@@ -29,7 +30,7 @@ class TestLoad(SearxTestCase):self.assertEqual(settings_loader.existing_filename_or_none(bad_settings_path), bad_settings_path)-class TestDefaultSettings(SearxTestCase):+class TestDefaultSettings(SearxTestCase): # pylint: disable=missing-class-docstringdef test_load(self):settings, msg = settings_loader.load_settings(load_user_settings=False)self.assertTrue(msg.startswith('load the default settings from'))@@ -43,7 +44,7 @@ class TestDefaultSettings(SearxTestCase):self.assertTrue(isinstance(settings['default_doi_resolver'], str))-class TestUserSettings(SearxTestCase):+class TestUserSettings(SearxTestCase): # pylint: disable=missing-class-docstringdef test_is_use_default_settings(self):self.assertFalse(settings_loader.is_use_default_settings({}))self.assertTrue(settings_loader.is_use_default_settings({'use_default_settings': True}))diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.pyindex dcb2cb9f2..1a6fba46d 100644--- a/tests/unit/test_utils.py+++ b/tests/unit/test_utils.py@@ -1,4 +1,6 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring, invalid-name+import lxml.etreefrom lxml import html@@ -8,7 +10,7 @@ from searx import utilsfrom tests import SearxTestCase-class TestUtils(SearxTestCase):+class TestUtils(SearxTestCase): # pylint: disable=missing-class-docstringdef test_gen_useragent(self):self.assertIsInstance(utils.gen_useragent(), str)self.assertIsNotNone(utils.gen_useragent())@@ -85,8 +87,8 @@ class TestUtils(SearxTestCase):utils.extract_url([], 'https://example.com')def test_html_to_text_invalid(self):- html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'- self.assertEqual(utils.html_to_text(html), "Lorem ipsum")+ _html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'+ self.assertEqual(utils.html_to_text(_html), "Lorem ipsum")def test_ecma_unscape(self):self.assertEqual(utils.ecma_unescape('text%20with%20space'), 'text with space')@@ -94,9 +96,9 @@ class TestUtils(SearxTestCase):self.assertEqual(utils.ecma_unescape('text using %u: %u5409, %u4E16%u754c'), 'text using %u: 吉, 世界')-class TestHTMLTextExtractor(SearxTestCase):+class TestHTMLTextExtractor(SearxTestCase): # pylint: disable=missing-class-docstringdef setUp(self):- self.html_text_extractor = utils._HTMLTextExtractor()+ self.html_text_extractor = utils._HTMLTextExtractor() # pylint: disable=protected-accessdef test__init__(self):self.assertEqual(self.html_text_extractor.result, [])@@ -117,11 +119,11 @@ class TestHTMLTextExtractor(SearxTestCase):def test_invalid_html(self):text = '<p><b>Lorem ipsum</i>dolor sit amet</p>'- with self.assertRaises(utils._HTMLTextExtractorException):+ with self.assertRaises(utils._HTMLTextExtractorException): # pylint: disable=protected-accessself.html_text_extractor.feed(text)-class TestXPathUtils(SearxTestCase):+class TestXPathUtils(SearxTestCase): # pylint: disable=missing-class-docstringTEST_DOC = """<ul><li>Text in <b>bold</b> and <i>italic</i> </li>diff --git a/tests/unit/test_webadapter.py b/tests/unit/test_webadapter.pyindex 2aa5cba8b..493020859 100644--- a/tests/unit/test_webadapter.py+++ b/tests/unit/test_webadapter.py@@ -1,4 +1,5 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringfrom searx.preferences import Preferencesfrom searx.engines import engines@@ -24,19 +25,19 @@ TEST_ENGINES = [SEARCHQUERY = [EngineRef(PRIVATE_ENGINE_NAME, 'general')]-class ValidateQueryCase(SearxTestCase):+class ValidateQueryCase(SearxTestCase): # pylint: disable=missing-class-docstring@classmethoddef setUpClass(cls):searx.search.initialize(TEST_ENGINES)- def test_query_private_engine_without_token(self):+ def test_query_private_engine_without_token(self): # pylint:disable=invalid-namepreferences = Preferences(['simple'], ['general'], engines, [])valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences)self.assertEqual(len(valid), 0)self.assertEqual(len(unknown), 0)self.assertEqual(len(invalid_token), 1)- def test_query_private_engine_with_incorrect_token(self):+ def test_query_private_engine_with_incorrect_token(self): # pylint:disable=invalid-namepreferences_with_tokens = Preferences(['simple'], ['general'], engines, [])preferences_with_tokens.parse_dict({'tokens': 'bad-token'})valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens)@@ -44,7 +45,7 @@ class ValidateQueryCase(SearxTestCase):self.assertEqual(len(unknown), 0)self.assertEqual(len(invalid_token), 1)- def test_query_private_engine_with_correct_token(self):+ def test_query_private_engine_with_correct_token(self): # pylint:disable=invalid-namepreferences_with_tokens = Preferences(['simple'], ['general'], engines, [])preferences_with_tokens.parse_dict({'tokens': 'my-token'})valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens)diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.pyindex 9e8bc24ce..868645e17 100644--- a/tests/unit/test_webapp.py+++ b/tests/unit/test_webapp.py@@ -1,4 +1,5 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstringimport jsonfrom urllib.parse import ParseResult@@ -11,15 +12,15 @@ from searx.preferences import Preferencesfrom tests import SearxTestCase-class ViewsTestCase(SearxTestCase):+class ViewsTestCase(SearxTestCase): # pylint: disable=missing-class-docstring, too-many-public-methodsdef setUp(self):# skip init function (no external HTTP request)- def dummy(*args, **kwargs):+ def dummy(*args, **kwargs): # pylint: disable=unused-argumentpassself.setattr4test(searx.search.processors, 'initialize_processor', dummy)- from searx import webapp # pylint disable=import-outside-toplevel+ from searx import webapp # pylint: disable=import-outside-toplevelwebapp.app.config['TESTING'] = True # to get better error messagesself.app = webapp.app.test_client()@@ -60,10 +61,10 @@ class ViewsTestCase(SearxTestCase):Timing(engine='youtube', total=0.9, load=0.6),]- def search_mock(search_self, *args):+ def search_mock(search_self, *args): # pylint: disable=unused-argumentsearch_self.result_container = Mock(get_ordered_results=lambda: test_results,- answers=dict(),+ answers={},corrections=set(),suggestions=set(),infoboxes=[],@@ -87,7 +88,8 @@ class ViewsTestCase(SearxTestCase):self.setattr4test(Preferences, 'get_value', preferences_get_value)- self.maxDiff = None # to see full diffs+ # to see full diffs+ self.maxDiff = None # pylint: disable=invalid-namedef test_index_empty(self):result = self.app.post('/')diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.pyindex b4395539b..c6c441dab 100644--- a/tests/unit/test_webutils.py+++ b/tests/unit/test_webutils.py@@ -1,10 +1,12 @@-# -*- coding: utf-8 -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=missing-module-docstring+import mockfrom searx import webutilsfrom tests import SearxTestCase-class TestWebUtils(SearxTestCase):+class TestWebUtils(SearxTestCase): # pylint: disable=missing-class-docstringdef test_prettify_url(self):data = (('https://searx.me/', 'https://searx.me/'),@@ -32,6 +34,7 @@ class TestWebUtils(SearxTestCase):query = 'a test'self.assertEqual(webutils.highlight_content(content, query), '<span class="highlight">a</span>')+ # pylint: disable=line-too-longdata = (('" test "', 'a test string', 'a <span class="highlight">test</span> string'),('"a"', 'this is a test string', 'this is <span class="highlight">a</span> test string'),@@ -67,7 +70,7 @@ class TestWebUtils(SearxTestCase):self.assertEqual(webutils.highlight_content(content, query), expected)-class TestUnicodeWriter(SearxTestCase):+class TestUnicodeWriter(SearxTestCase): # pylint: disable=missing-class-docstringdef setUp(self):self.unicode_writer = webutils.CSVWriter(mock.MagicMock())@@ -82,7 +85,7 @@ class TestUnicodeWriter(SearxTestCase):self.assertEqual(self.unicode_writer.writerow.call_count, len(rows))-class TestNewHmac(SearxTestCase):+class TestNewHmac(SearxTestCase): # pylint: disable=missing-class-docstringdef test_bytes(self):data = b'http://example.com'with self.assertRaises(AttributeError):diff --git a/utils/lib_sxng_test.sh b/utils/lib_sxng_test.shindex 1bba9aa4c..e0a4fe6f0 100755--- a/utils/lib_sxng_test.sh+++ b/utils/lib_sxng_test.sh@@ -1,13 +1,11 @@#!/usr/bin/env bash# SPDX-License-Identifier: AGPL-3.0-or-later-[[ -z "${PYLINT_OPTIONS}" ]] && PYLINT_OPTIONS="-j 0 --rcfile .pylintrc"-test.help(){cat <<EOFtest.:yamllint : lint YAML files (YAMLLINT_FILES)- pylint : lint PYLINT_FILES, searx/engines, searx & tests+ pylint : lint ./searx, ./searxng_extra and ./testspyright : static type check of python sourcesblack : check black code formatunit : run unit tests@@ -28,21 +26,19 @@ test.pylint() {# shellcheck disable=SC2086( set -epyenv.activate+ PYLINT_OPTIONS="--rcfile .pylintrc"- build_msg TEST "[pylint] \$PYLINT_FILES"- pylint ${PYLINT_OPTIONS} ${PYLINT_VERBOSE} \- "${PYLINT_FILES[@]}"-- build_msg TEST "[pylint] searx/engines"+ build_msg TEST "[pylint] ./searx/engines"pylint ${PYLINT_OPTIONS} ${PYLINT_VERBOSE} \--additional-builtins="traits,supported_languages,language_aliases,logger,categories" \searx/engines- build_msg TEST "[pylint] searx tests"+ build_msg TEST "[pylint] ./searx ./searxng_extra ./tests"pylint ${PYLINT_OPTIONS} ${PYLINT_VERBOSE} \- --disable="${PYLINT_SEARXNG_DISABLE_OPTION}" \--ignore=searx/engines \- searx tests+ searx searx/searxng.msg \+ searxng_extra searxng_extra/docs_prebuild \+ tests)dump_return $?}diff --git a/utils/searxng_check.py b/utils/searxng_check.pyindex 3d2614fd4..0bff756ad 100644--- a/utils/searxng_check.py+++ b/utils/searxng_check.py@@ -1,5 +1,4 @@# SPDX-License-Identifier: AGPL-3.0-or-later-# lint: pylint"""Implement some checks in the active installation"""