summaryrefslogtreecommitdiff
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
parent8205f170ff983e5240d32dc17d7fdb526ebe5fe7 (diff)
downloadsearx-542f7d0d7bd1a12e1884ba4a1508b40e2514d472.tar.gz
searx-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>
-rw-r--r--.pylintrc2
-rw-r--r--docs/conf.py1
-rw-r--r--examples/basic_engine.py25
-rwxr-xr-xmanage21
-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
-rw-r--r--searxng_extra/__init__.py2
-rwxr-xr-xsearxng_extra/docs_prebuild12
-rwxr-xr-xsearxng_extra/standalone_searx.py3
-rw-r--r--searxng_extra/update/__init__.py2
-rwxr-xr-xsearxng_extra/update/update_ahmia_blacklist.py1
-rwxr-xr-xsearxng_extra/update/update_currencies.py2
-rwxr-xr-xsearxng_extra/update/update_engine_descriptions.py2
-rwxr-xr-xsearxng_extra/update/update_engine_traits.py3
-rwxr-xr-xsearxng_extra/update/update_external_bangs.py1
-rwxr-xr-xsearxng_extra/update/update_firefox_version.py1
-rwxr-xr-xsearxng_extra/update/update_locales.py1
-rwxr-xr-xsearxng_extra/update/update_osm_keys_tags.py1
-rwxr-xr-xsearxng_extra/update/update_pygments.py1
-rwxr-xr-xsearxng_extra/update/update_wikidata_units.py3
-rw-r--r--setup.py2
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/robot/__init__.py2
-rw-r--r--tests/robot/__main__.py1
-rw-r--r--tests/robot/test_webapp.py1
-rw-r--r--tests/unit/__init__.py3
-rw-r--r--tests/unit/engines/test_command.py3
-rw-r--r--tests/unit/engines/test_xpath.py4
-rw-r--r--tests/unit/network/__init__.py2
-rw-r--r--tests/unit/network/test_network.py15
-rw-r--r--tests/unit/test_answerers.py5
-rw-r--r--tests/unit/test_engines_init.py13
-rw-r--r--tests/unit/test_exceptions.py3
-rw-r--r--tests/unit/test_external_bangs.py13
-rw-r--r--tests/unit/test_locales.py3
-rw-r--r--tests/unit/test_plugins.py16
-rw-r--r--tests/unit/test_preferences.py11
-rw-r--r--tests/unit/test_query.py13
-rw-r--r--tests/unit/test_results.py6
-rw-r--r--tests/unit/test_search.py9
-rw-r--r--tests/unit/test_settings_loader.py7
-rw-r--r--tests/unit/test_utils.py18
-rw-r--r--tests/unit/test_webadapter.py11
-rw-r--r--tests/unit/test_webapp.py16
-rw-r--r--tests/unit/test_webutils.py11
-rwxr-xr-xutils/lib_sxng_test.sh18
-rw-r--r--utils/searxng_check.py1
118 files changed, 259 insertions, 367 deletions
diff --git a/.pylintrc b/.pylintrc
index 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.py
index 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-later
import sys, os
diff --git a/examples/basic_engine.py b/examples/basic_engine.py
deleted file mode 100644
index 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/manage
index 9871906d2..33e2808e1 100755
--- a/manage
+++ b/manage
@@ -52,23 +52,6 @@ if [ -S "${_dev_redis_sock}" ] && [ -z "${SEARXNG_REDIS_URL}" ]; then
export 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; do
YAMLLINT_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.help
cat <<EOF
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
diff --git a/searxng_extra/__init__.py b/searxng_extra/__init__.py
index 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-docstring
diff --git a/searxng_extra/docs_prebuild b/searxng_extra/docs_prebuild
index 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 sys
import os.path
import time
from contextlib import contextmanager
+
from searx import settings, get_setting, locales
from 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 (no
links 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's
diff --git a/searxng_extra/standalone_searx.py b/searxng_extra/standalone_searx.py
index 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__.py
index 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-docstring
diff --git a/searxng_extra/update/update_ahmia_blacklist.py b/searxng_extra/update/update_ahmia_blacklist.py
index 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.py
index 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.py
index 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.py
index 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.py
index 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 bangs
from :py:obj:`BANGS_URL`.
diff --git a/searxng_extra/update/update_firefox_version.py b/searxng_extra/update/update_firefox_version.py
index 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 signatures
diff --git a/searxng_extra/update/update_locales.py b/searxng_extra/update/update_locales.py
index 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.py
index 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.py
index 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 style
diff --git a/searxng_extra/update/update_wikidata_units.py b/searxng_extra/update/update_wikidata_units.py
index 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 data
diff --git a/setup.py b/setup.py
index 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_packages
diff --git a/tests/__init__.py b/tests/__init__.py
index 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 os
import aiounittest
os.environ.pop('SEARX_DEBUG', None)
diff --git a/tests/robot/__init__.py b/tests/robot/__init__.py
index 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-import
diff --git a/tests/robot/__main__.py b/tests/robot/__main__.py
index 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-docstring
diff --git a/tests/robot/test_webapp.py b/tests/robot/test_webapp.py
index 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-docstring
from time import sleep
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index 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 os
from os.path import dirname, sep, abspath
diff --git a/tests/unit/engines/test_command.py b/tests/unit/engines/test_command.py
index 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 modify
it under the terms of the GNU Affero General Public License as published by
diff --git a/tests/unit/engines/test_xpath.py b/tests/unit/engines/test_xpath.py
index 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 defaultdict
import mock
from searx.engines import xpath
diff --git a/tests/unit/network/__init__.py b/tests/unit/network/__init__.py
index 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-docstring
diff --git a/tests/unit/network/test_network.py b/tests/unit/network/test_network.py
index 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-access
from mock import patch
@@ -8,7 +9,7 @@ from searx.network.network import Network, NETWORKS, initialize
from tests import SearxTestCase
-class TestNetwork(SearxTestCase):
+class TestNetwork(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self):
initialize()
@@ -121,7 +122,7 @@ class TestNetwork(SearxTestCase):
await network.aclose()
-class TestNetworkRequestRetries(SearxTestCase):
+class TestNetworkRequestRetries(SearxTestCase): # pylint: disable=missing-class-docstring
TEXT = '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-argument
nonlocal first
if 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-argument
nonlocal request_count
request_count += 1
if request_count < 3:
@@ -194,7 +195,7 @@ class TestNetworkRequestRetries(SearxTestCase):
await network.aclose()
-class TestNetworkStreamRetries(SearxTestCase):
+class TestNetworkStreamRetries(SearxTestCase): # pylint: disable=missing-class-docstring
TEXT = '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-argument
nonlocal first
if 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-argument
nonlocal first
if first:
first = False
diff --git a/tests/unit/test_answerers.py b/tests/unit/test_answerers.py
index 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-docstring
from mock import Mock
@@ -6,7 +7,7 @@ from searx.answerers import answerers
from tests import SearxTestCase
-class AnswererTest(SearxTestCase):
+class AnswererTest(SearxTestCase): # pylint: disable=missing-class-docstring
def 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.py
index 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, engines
from tests import SearxTestCase
-class TestEnginesInit(SearxTestCase):
+class TestEnginesInit(SearxTestCase): # pylint: disable=missing-class-docstring
@classmethod
def 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-name
settings['outgoing']['using_tor_proxy'] = False
engine_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-name
settings['outgoing']['using_tor_proxy'] = True
settings['outgoing']['extra_proxy_timeout'] = 100.0
engine_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-name
engines.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-name
engines.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.py
index 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-docstring
from tests import SearxTestCase
import searx.exceptions
from searx import get_setting
-class TestExceptions(SearxTestCase):
+class TestExceptions(SearxTestCase): # pylint: disable=missing-class-docstring
def 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.py
index 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-docstring
def 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-docstring
def 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-docstring
def 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.py
index 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 locales
diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py
index 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 Mock
from searx import (
plugins,
@@ -6,21 +9,20 @@ from searx import (
botdetection,
)
-from mock import Mock
from tests import SearxTestCase
def 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-methods
default_on = False
name = 'Default plugin'
description = 'Default plugin description'
-class PluginStoreTest(SearxTestCase):
+class PluginStoreTest(SearxTestCase): # pylint: disable=missing-class-docstring
def 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-docstring
def 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-docstring
def 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.py
index 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_initialize
from searx.preferences import (
EnumStringSetting,
@@ -12,13 +15,13 @@ from tests import SearxTestCase
locales_initialize()
-class PluginStub:
+class PluginStub: # pylint: disable=missing-class-docstring, too-few-public-methods
def __init__(self, plugin_id, default_on):
self.id = plugin_id
self.default_on = default_on
-class TestSettings(SearxTestCase):
+class TestSettings(SearxTestCase): # pylint: disable=missing-class-docstring
# map settings
def 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-docstring
def test_encode(self):
- from searx.preferences import Preferences
+ from searx.preferences import Preferences # pylint: disable=import-outside-toplevel
pref = Preferences(['simple'], ['general'], {}, [])
url_params = (
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py
index 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 settings
from searx.engines import load_engines
from searx.query import RawTextQuery
@@ -16,7 +19,7 @@ TEST_ENGINES = [
]
-class TestQuery(SearxTestCase):
+class TestQuery(SearxTestCase): # pylint:disable=missing-class-docstring
def 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-docstring
def 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-docstring
def 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-docstring
def 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-docstring
SPECIFIC_BANGS = ['!dummy_engine', '!du', '!general']
THE_QUERY = 'the query'
diff --git a/tests/unit/test_results.py b/tests/unit/test_results.py
index 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-docstring
from searx.results import ResultContainer
from tests import SearxTestCase
@@ -17,8 +18,7 @@ def fake_result(url='https://aa.bb/cc?dd=ee#ff', title='aaa', content='bbb', eng
return result
-# TODO
-class ResultContainerTestCase(SearxTestCase):
+class ResultContainerTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def test_empty(self):
c = ResultContainer()
self.assertEqual(c.get_ordered_results(), [])
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index 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-name
from copy import copy
@@ -23,7 +24,7 @@ TEST_ENGINES = [
]
-class SearchQueryTestCase(SearxTestCase):
+class SearchQueryTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def 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-docstring
def setUp(self):
- from searx import webapp # pylint disable=import-outside-toplevel
+ from searx import webapp # pylint: disable=import-outside-toplevel
self.app = webapp.app
diff --git a/tests/unit/test_settings_loader.py b/tests/unit/test_settings_loader.py
index 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-docstring
from os.path import dirname, join, abspath
from unittest.mock import patch
@@ -11,7 +12,7 @@ from tests import SearxTestCase
test_dir = abspath(dirname(__file__))
-class TestLoad(SearxTestCase):
+class TestLoad(SearxTestCase): # pylint: disable=missing-class-docstring
def 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-docstring
def 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-docstring
def 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.py
index 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.etree
from lxml import html
@@ -8,7 +10,7 @@ from searx import utils
from tests import SearxTestCase
-class TestUtils(SearxTestCase):
+class TestUtils(SearxTestCase): # pylint: disable=missing-class-docstring
def 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-docstring
def setUp(self):
- self.html_text_extractor = utils._HTMLTextExtractor()
+ self.html_text_extractor = utils._HTMLTextExtractor() # pylint: disable=protected-access
def 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-access
self.html_text_extractor.feed(text)
-class TestXPathUtils(SearxTestCase):
+class TestXPathUtils(SearxTestCase): # pylint: disable=missing-class-docstring
TEST_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.py
index 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-docstring
from searx.preferences import Preferences
from 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
@classmethod
def 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-name
preferences = 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-name
preferences_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-name
preferences_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.py
index 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-docstring
import json
from urllib.parse import ParseResult
@@ -11,15 +12,15 @@ from searx.preferences import Preferences
from tests import SearxTestCase
-class ViewsTestCase(SearxTestCase):
+class ViewsTestCase(SearxTestCase): # pylint: disable=missing-class-docstring, too-many-public-methods
def setUp(self):
# skip init function (no external HTTP request)
- def dummy(*args, **kwargs):
+ def dummy(*args, **kwargs): # pylint: disable=unused-argument
pass
self.setattr4test(searx.search.processors, 'initialize_processor', dummy)
- from searx import webapp # pylint disable=import-outside-toplevel
+ from searx import webapp # pylint: disable=import-outside-toplevel
webapp.app.config['TESTING'] = True # to get better error messages
self.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-argument
search_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-name
def test_index_empty(self):
result = self.app.post('/')
diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py
index 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 mock
from searx import webutils
from tests import SearxTestCase
-class TestWebUtils(SearxTestCase):
+class TestWebUtils(SearxTestCase): # pylint: disable=missing-class-docstring
def 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-long
data = (
('" 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-docstring
def 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-docstring
def 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.sh
index 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 <<EOF
test.:
yamllint : lint YAML files (YAMLLINT_FILES)
- pylint : lint PYLINT_FILES, searx/engines, searx & tests
+ pylint : lint ./searx, ./searxng_extra and ./tests
pyright : static type check of python sources
black : check black code format
unit : run unit tests
@@ -28,21 +26,19 @@ test.pylint() {
# shellcheck disable=SC2086
( set -e
pyenv.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.py
index 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
"""