mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 10:32:21 +02:00
[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>
This commit is contained in:
parent
8205f170ff
commit
542f7d0d7b
118 changed files with 261 additions and 369 deletions
|
@ -1,5 +1,4 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# lint: pylint
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
import typing
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue