diff --git a/.pylintrc b/.pylintrc index f2dd716d..51cea773 100644 --- a/.pylintrc +++ b/.pylintrc @@ -59,8 +59,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=bad-whitespace, - duplicate-code, +disable=duplicate-code, missing-function-docstring, consider-using-f-string, @@ -108,39 +107,21 @@ max-nested-blocks=5 [BASIC] -# List of builtins function names that should not be used, separated by a comma -bad-functions=map,filter,apply,input - -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct argument names argument-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*)|([A-Z0-9_]*))$ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$ #const-rgx=[f]?[A-Z_][a-zA-Z0-9_]{2,30}$ @@ -149,9 +130,6 @@ const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$ # ones are exempt. docstring-min-length=-1 -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$ @@ -161,21 +139,12 @@ good-names=i,j,k,ex,Run,_,log,cfg,id # Include a hint for the correct naming format with invalid-name include-naming-hint=no -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names #module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ module-rgx=([a-z_][a-z0-9_]*)$ @@ -192,9 +161,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*)|([a-z]))$ @@ -220,12 +186,6 @@ max-line-length=120 # Maximum number of lines in a module max-module-lines=2000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement.No config file found, using default configuration diff --git a/requirements-dev.txt b/requirements-dev.txt index 03e0e35f..49cfbf99 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ nose2[coverage_plugin]==0.11.0 cov-core==1.15.0 black==22.3.0 pycodestyle==2.8.0 -pylint==2.13.9 +pylint==2.14.0 splinter==0.17.0 selenium==4.1.5 twine==4.0.1 diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 592a51ec..b7c318e5 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -464,7 +464,6 @@ def get_attributes(language): class WDAttribute: - # pylint: disable=no-self-use __slots__ = ('name',) def __init__(self, name): @@ -626,7 +625,6 @@ class WDImageAttribute(WDURLAttribute): class WDDateAttribute(WDAttribute): - # pylint: disable=no-self-use def get_select(self): return '?{name} ?{name}timePrecision ?{name}timeZone ?{name}timeCalendar'.replace('{name}', self.name) diff --git a/searx/infopage/__init__.py b/searx/infopage/__init__.py index f8be73f0..4aebfa5a 100644 --- a/searx/infopage/__init__.py +++ b/searx/infopage/__init__.py @@ -81,7 +81,7 @@ class InfoPage: MarkdownIt("commonmark", {"typographer": True}).enable(["replacements", "smartquotes"]).render(self.content) ) - def get_ctx(self): # pylint: disable=no-self-use + def get_ctx(self): """Jinja context to render :py:obj:`InfoPage.content`""" def _md_link(name, url): diff --git a/searx/metrics/__init__.py b/searx/metrics/__init__.py index bc755b96..18d2170d 100644 --- a/searx/metrics/__init__.py +++ b/searx/metrics/__init__.py @@ -160,6 +160,7 @@ def get_reliabilities(engline_name_list, checker_results): # even if there is no exception reliablity = 0 else: + # pylint: disable=consider-using-generator reliablity = 100 - sum([error['percentage'] for error in errors if not error.get('secondary')]) reliabilities[engine_name] = { diff --git a/searx/network/__init__.py b/searx/network/__init__.py index e8dddd6a..06c9f75a 100644 --- a/searx/network/__init__.py +++ b/searx/network/__init__.py @@ -13,7 +13,7 @@ from typing import Iterable, Tuple import httpx import anyio -from .network import get_network, initialize, check_network_configuration +from .network import get_network, initialize, check_network_configuration # pylint:disable=cyclic-import from .client import get_loop from .raise_for_httperror import raise_for_httperror diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 3d431f32..8ece9435 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -198,7 +198,6 @@ class PluginStore: self.plugins.append(plugin) def call(self, ordered_plugin_list, plugin_type, *args, **kwargs): - # pylint: disable=no-self-use ret = True for plugin in ordered_plugin_list: if hasattr(plugin, plugin_type): diff --git a/searx/plugins/search_on_category_select.py b/searx/plugins/search_on_category_select.py index 99066e23..85b73a9b 100644 --- a/searx/plugins/search_on_category_select.py +++ b/searx/plugins/search_on_category_select.py @@ -18,7 +18,7 @@ from flask_babel import gettext name = gettext('Search on category select') description = gettext( - 'Perform search immediately if a category selected. ' 'Disable to select multiple categories. (JavaScript required)' + 'Perform search immediately if a category selected. Disable to select multiple categories. (JavaScript required)' ) default_on = True preference_section = 'ui' diff --git a/searx/preferences.py b/searx/preferences.py index cd943af6..46b7b39d 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -208,11 +208,9 @@ class BooleanChoices: self.default_choices = dict(choices) def transform_form_items(self, items): - # pylint: disable=no-self-use return items def transform_values(self, values): - # pylint: disable=no-self-use return values def parse_cookie(self, data_disabled: str, data_enabled: str): diff --git a/searx/search/__init__.py b/searx/search/__init__.py index e790bd05..c517814d 100644 --- a/searx/search/__init__.py +++ b/searx/search/__init__.py @@ -133,7 +133,7 @@ class Search: def search_multiple_requests(self, requests): # pylint: disable=protected-access - search_id = uuid4().__str__() + search_id = str(uuid4()) for engine_name, query, request_params in requests: th = threading.Thread( # pylint: disable=invalid-name diff --git a/searx/search/processors/abstract.py b/searx/search/processors/abstract.py index b7703496..d4822fc5 100644 --- a/searx/search/processors/abstract.py +++ b/searx/search/processors/abstract.py @@ -170,5 +170,5 @@ class EngineProcessor(ABC): tests.update(self.get_default_tests()) return tests - def get_default_tests(self): # pylint: disable=no-self-use + def get_default_tests(self): return {} diff --git a/searx/utils.py b/searx/utils.py index abc330be..15f4d709 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -464,7 +464,7 @@ def to_string(obj: Any) -> str: if isinstance(obj, str): return obj if hasattr(obj, '__str__'): - return obj.__str__() + return str(obj) return repr(obj) diff --git a/searx/webapp.py b/searx/webapp.py index fa5ca060..493468a2 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1048,6 +1048,7 @@ def preferences(): # even if there is no exception reliablity = 0 else: + # pylint: disable=consider-using-generator reliablity = 100 - sum([error['percentage'] for error in errors if not error.get('secondary')]) reliabilities[e.name] = {