From 24f2376c1185dbc0a31ca7d8a777225cf7bea39a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 3 Jul 2021 17:51:39 +0200 Subject: [PATCH 1/2] [pylint] prepare for pylint v2.9.3 / fix some (new) pylint issues Upgrade from pylint v2.8.3 to 2.9.3 raise some new issues:: searx/search/checker/__main__.py:37:26: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) searx/search/checker/__main__.py:38:26: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) searx/search/processors/__init__.py:20:0: R0402: Use 'from searx import engines' instead (consider-using-from-import) searx/preferences.py:182:19: C0207: Use data.split('-', maxsplit=1)[0] instead (use-maxsplit-arg) searx/preferences.py:506:15: R1733: Unnecessary dictionary index lookup, use 'user_setting' instead (unnecessary-dict-index-lookup) searx/webapp.py:436:0: C0206: Consider iterating with .items() (consider-using-dict-items) searx/webapp.py:950:4: C0206: Consider iterating with .items() (consider-using-dict-items) Signed-off-by: Markus Heiser --- searx/preferences.py | 3 ++- searx/search/checker/__main__.py | 12 ++++++++++-- searx/search/processors/__init__.py | 2 +- searx/webapp.py | 4 +++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/searx/preferences.py b/searx/preferences.py index b63bd446b..e4a2ebecd 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -179,7 +179,7 @@ class SearchLanguageSetting(EnumStringSetting): if data not in self.choices and data != self.value: # pylint: disable=no-member # hack to give some backwards compatibility with old language cookies data = str(data).replace('_', '-') - lang = data.split('-')[0] + lang = data.split('-', maxsplit=1)[0] # pylint: disable=no-member if data in self.choices: pass @@ -503,6 +503,7 @@ class Preferences: """Save cookie in the HTTP reponse obect """ for user_setting_name, user_setting in self.key_value_settings.items(): + # pylint: disable=unnecessary-dict-index-lookup if self.key_value_settings[user_setting_name].locked: continue user_setting.save(user_setting_name, resp) diff --git a/searx/search/checker/__main__.py b/searx/search/checker/__main__.py index 7a85347cc..e1de860b7 100644 --- a/searx/search/checker/__main__.py +++ b/searx/search/checker/__main__.py @@ -34,8 +34,16 @@ else: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = "", "", "", "", "", "", "", "" # equivalent of 'python -u' (unbuffered stdout, stderr) -stdout = io.TextIOWrapper(open(sys.stdout.fileno(), 'wb', 0), write_through=True) -stderr = io.TextIOWrapper(open(sys.stderr.fileno(), 'wb', 0), write_through=True) +stdout = io.TextIOWrapper( + # pylint: disable=consider-using-with + open(sys.stdout.fileno(), 'wb', 0), + write_through=True +) +stderr = io.TextIOWrapper( + # pylint: disable=consider-using-with + open(sys.stderr.fileno(), 'wb', 0) + , write_through=True +) # iterator of processors diff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.py index d5ebdb70c..b3d121f0e 100644 --- a/searx/search/processors/__init__.py +++ b/searx/search/processors/__init__.py @@ -17,7 +17,7 @@ __all__ = [ import threading from searx import logger -import searx.engines as engines +from searx import engines from .online import OnlineProcessor from .offline import OfflineProcessor diff --git a/searx/webapp.py b/searx/webapp.py index 6a3562c1c..4d838062b 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -433,6 +433,7 @@ def _get_ordered_categories(): def _get_enable_categories(all_categories): disabled_engines = request.preferences.engines.get_disabled() enabled_categories = set( + # pylint: disable=consider-using-dict-items category for engine_name in engines for category in engines[engine_name].categories if (engine_name, category) not in disabled_engines @@ -947,7 +948,8 @@ def preferences(): ) engines_by_category = {} - for c in categories: + + for c in categories: # pylint: disable=consider-using-dict-items engines_by_category[c] = [e for e in categories[c] if e.name in filtered_engines] # sort the engines alphabetically since the order in settings.yml is meaningless. list.sort(engines_by_category[c], key=lambda e: e.name) From 19e2b7236776228b2ea3b05b106a5e68ac9b557d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jul 2021 07:04:56 +0000 Subject: [PATCH 2/2] Bump pylint from 2.8.3 to 2.9.3 Bumps [pylint](https://github.com/PyCQA/pylint) from 2.8.3 to 2.9.3. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Changelog](https://github.com/PyCQA/pylint/blob/main/ChangeLog) - [Commits](https://github.com/PyCQA/pylint/compare/v2.8.3...v2.9.3) --- 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 a4ef3a948..4ab1e0c51 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ mock==4.0.3 nose2[coverage_plugin]==0.10.0 cov-core==1.15.0 pycodestyle==2.7.0 -pylint==2.8.3 +pylint==2.9.3 splinter==0.14.0 transifex-client==0.14.2 selenium==3.141.0