From 4c06837a5047a5d3a7ae9bd5ec9fb38f86eb5268 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 10 Feb 2023 13:40:12 +0100 Subject: [PATCH 01/19] [mod] make python code pylint 2.16.1 compliant Signed-off-by: Markus Heiser --- .pylintrc | 2 +- searx/autocomplete.py | 1 + searx/engines/crossref.py | 1 + searx/engines/docker_hub.py | 1 + searx/engines/gigablast.py | 2 +- searx/search/processors/online.py | 1 + searx/webapp.py | 2 ++ searxng_extra/update/update_ahmia_blacklist.py | 2 ++ searxng_extra/update/update_firefox_version.py | 3 ++- 9 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index 51cea773e..a5b00227e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -404,4 +404,4 @@ known-third-party=enchant # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 6fb5537a2..aeb697a14 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -3,6 +3,7 @@ """This module implements functions needed for the autocompleter. """ +# pylint: disable=use-dict-literal from json import loads from urllib.parse import urlencode diff --git a/searx/engines/crossref.py b/searx/engines/crossref.py index fbe2f0c2a..e12a0da5b 100644 --- a/searx/engines/crossref.py +++ b/searx/engines/crossref.py @@ -2,6 +2,7 @@ # lint: pylint """Semantic Scholar (Science) """ +# pylint: disable=use-dict-literal from urllib.parse import urlencode from searx.utils import html_to_text diff --git a/searx/engines/docker_hub.py b/searx/engines/docker_hub.py index 1e492b196..cde96d016 100644 --- a/searx/engines/docker_hub.py +++ b/searx/engines/docker_hub.py @@ -3,6 +3,7 @@ """Docker Hub (IT) """ +# pylint: disable=use-dict-literal from json import loads from urllib.parse import urlencode diff --git a/searx/engines/gigablast.py b/searx/engines/gigablast.py index 1c40ff331..382711b10 100644 --- a/searx/engines/gigablast.py +++ b/searx/engines/gigablast.py @@ -3,7 +3,7 @@ """ Gigablast (Web) """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name, use-dict-literal import re from time import time diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py index dd5d1e36b..242718416 100644 --- a/searx/search/processors/online.py +++ b/searx/search/processors/online.py @@ -4,6 +4,7 @@ """Processores for engine-type: ``online`` """ +# pylint: disable=use-dict-literal from timeit import default_timer import asyncio diff --git a/searx/webapp.py b/searx/webapp.py index d9ca3941c..07225908c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -5,6 +5,8 @@ """WebbApp """ +# pylint: disable=use-dict-literal + import hashlib import hmac import json diff --git a/searxng_extra/update/update_ahmia_blacklist.py b/searxng_extra/update/update_ahmia_blacklist.py index 26c485195..a11413f14 100755 --- a/searxng_extra/update/update_ahmia_blacklist.py +++ b/searxng_extra/update/update_ahmia_blacklist.py @@ -9,6 +9,7 @@ Output file: :origin:`searx/data/ahmia_blacklist.txt` (:origin:`CI Update data .. _Ahmia's blacklist: https://ahmia.fi/blacklist/ """ +# pylint: disable=use-dict-literal from os.path import join @@ -21,6 +22,7 @@ URL = 'https://ahmia.fi/blacklist/banned/' def fetch_ahmia_blacklist(): resp = requests.get(URL, timeout=3.0) if resp.status_code != 200: + # pylint: disable=broad-exception-raised raise Exception("Error fetching Ahmia blacklist, HTTP code " + resp.status_code) return resp.text.split() diff --git a/searxng_extra/update/update_firefox_version.py b/searxng_extra/update/update_firefox_version.py index 384d0002f..51aec39c5 100755 --- a/searxng_extra/update/update_firefox_version.py +++ b/searxng_extra/update/update_firefox_version.py @@ -1,13 +1,13 @@ #!/usr/bin/env python # lint: pylint # SPDX-License-Identifier: AGPL-3.0-or-later - """Fetch firefox useragent signatures Output file: :origin:`searx/data/useragents.json` (:origin:`CI Update data ... <.github/workflows/data-update.yml>`). """ +# pylint: disable=use-dict-literal import json import re @@ -40,6 +40,7 @@ useragents = { def fetch_firefox_versions(): resp = requests.get(URL, timeout=2.0) if resp.status_code != 200: + # pylint: disable=broad-exception-raised raise Exception("Error fetching firefox versions, HTTP code " + resp.status_code) dom = html.fromstring(resp.text) versions = [] From f1a3872aeb8bef5eefb248d93d69b49f42d16b32 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 07:56:46 +0000 Subject: [PATCH 02/19] Bump pylint from 2.15.10 to 2.16.1 Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.10 to 2.16.1. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Commits](https://github.com/PyCQA/pylint/compare/v2.15.10...v2.16.1) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0c4b07311..87c999c95 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ mock==5.0.1 nose2[coverage_plugin]==0.12.0 cov-core==1.15.0 black==22.12.0 -pylint==2.15.10 +pylint==2.16.1 splinter==0.19.0 selenium==4.8.0 twine==4.0.2 From a7284e0b9cecb6a5c625146bd598cdcb4dedcefe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 07:56:53 +0000 Subject: [PATCH 03/19] Bump redis from 4.4.2 to 4.5.1 Bumps [redis](https://github.com/redis/redis-py) from 4.4.2 to 4.5.1. - [Release notes](https://github.com/redis/redis-py/releases) - [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES) - [Commits](https://github.com/redis/redis-py/compare/v4.4.2...v4.5.1) --- updated-dependencies: - dependency-name: redis dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f30f43716..a261a0488 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ Brotli==1.0.9 uvloop==0.17.0 httpx-socks[asyncio]==0.7.2 setproctitle==1.3.2 -redis==4.4.2 +redis==4.5.1 markdown-it-py==2.1.0 typing_extensions==4.4.0 fasttext-predict==0.9.2.1 From 6707354bc81a0c7d16ca7db6ab6bd151813380d0 Mon Sep 17 00:00:00 2001 From: wibyweb <49052850+wibyweb@users.noreply.github.com> Date: Thu, 9 Feb 2023 00:53:39 -0500 Subject: [PATCH 04/19] [mod] engine wiby: add pagination Suggested by: @wibyweb in searx https://github.com/searx/searx/pull/3465 Signed-off-by: Markus Heiser --- searx/settings.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/searx/settings.yml b/searx/settings.yml index 216cb3c82..8bcd0c6a3 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1519,7 +1519,8 @@ engines: - name: wiby engine: json_engine - search_url: https://wiby.me/json/?q={query} + paging: true + search_url: https://wiby.me/json/?q={query}&p={pageno} url_query: URL title_query: Title content_query: Snippet From 9a710587e847f248b1f0ffcf1e1091e9fc2ec027 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 9 Feb 2023 18:42:59 +0100 Subject: [PATCH 05/19] [fix] remove usage of deprecated-module distutis Closes: https://github.com/searxng/searxng/issues/2168 Signed-off-by: Markus Heiser --- searxng_extra/update/update_firefox_version.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/searxng_extra/update/update_firefox_version.py b/searxng_extra/update/update_firefox_version.py index 51aec39c5..2e730764a 100755 --- a/searxng_extra/update/update_firefox_version.py +++ b/searxng_extra/update/update_firefox_version.py @@ -13,7 +13,7 @@ import json import re from os.path import join from urllib.parse import urlparse, urljoin -from distutils.version import LooseVersion # pylint: disable=deprecated-module +from packaging.version import parse import requests from lxml import html @@ -51,7 +51,7 @@ def fetch_firefox_versions(): if path.startswith(RELEASE_PATH): version = path[len(RELEASE_PATH) : -1] if NORMAL_REGEX.match(version): - versions.append(LooseVersion(version)) + versions.append(parse(version)) list.sort(versions, reverse=True) return versions @@ -61,11 +61,11 @@ def fetch_firefox_last_versions(): versions = fetch_firefox_versions() result = [] - major_last = versions[0].version[0] + major_last = versions[0].major major_list = (major_last, major_last - 1) for version in versions: - major_current = version.version[0] - minor_current = version.version[1] + major_current = version.major + minor_current = version.minor if major_current in major_list: user_agent_version = f'{major_current}.{minor_current}' if user_agent_version not in result: From 415f6398d61cd35c42ca23c0daf1fc6ba8f2e7a5 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 8 Feb 2023 06:54:19 +0100 Subject: [PATCH 06/19] [fix] time_range in HTML form should not be a string 'None' Before this patch SearXNG returns 'time_range': 'None'::
... ...
Signed-off-by: Markus Heiser --- searx/webapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/webapp.py b/searx/webapp.py index 07225908c..6746f7a00 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -817,7 +817,7 @@ def search(): q=request.form['q'], selected_categories = search_query.categories, pageno = search_query.pageno, - time_range = search_query.time_range, + time_range = search_query.time_range or '', number_of_results = format_decimal(number_of_results), suggestions = suggestion_urls, answers = result_container.answers, From a530ac4099e2dea47f7ccb70b2034bd7f8c9279e Mon Sep 17 00:00:00 2001 From: Lea Date: Tue, 17 Jan 2023 10:31:57 +0100 Subject: [PATCH 07/19] fix: typo in suggestions --- searx/templates/simple/results.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/templates/simple/results.html b/searx/templates/simple/results.html index 755610e5b..f73a25d09 100644 --- a/searx/templates/simple/results.html +++ b/searx/templates/simple/results.html @@ -65,7 +65,7 @@ {% if suggestions %}