From 7f89adc5f39a9b3d2a03d32728010d0a770b89a3 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 24 Jan 2022 09:53:30 +0100 Subject: [pyright:strict] searx.shared.shared_abstract --- searx/shared/shared_abstract.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'searx/shared') diff --git a/searx/shared/shared_abstract.py b/searx/shared/shared_abstract.py index b4b15bea6..af4be30ae 100644 --- a/searx/shared/shared_abstract.py +++ b/searx/shared/shared_abstract.py @@ -1,20 +1,22 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +# pyright: strict from abc import ABC, abstractmethod +from typing import Optional class SharedDict(ABC): @abstractmethod - def get_int(self, key): + def get_int(self, key: str) -> Optional[int]: pass @abstractmethod - def set_int(self, key, value): + def set_int(self, key: str, value: int): pass @abstractmethod - def get_str(self, key): + def get_str(self, key: str) -> Optional[str]: pass @abstractmethod - def set_str(self, key, value): + def set_str(self, key: str, value: str): pass -- cgit v1.2.3 From 640c404844e3b06482402c53fdce8a2295772d42 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 24 Jan 2022 09:46:32 +0100 Subject: [pyright:strict] searx.search.checker.background --- searx/shared/shared_simple.py | 9 +++++---- searx/shared/shared_uwsgi.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'searx/shared') diff --git a/searx/shared/shared_simple.py b/searx/shared/shared_simple.py index 0bf13a2a6..2b9d4c2da 100644 --- a/searx/shared/shared_simple.py +++ b/searx/shared/shared_simple.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later import threading +from typing import Optional from . import shared_abstract @@ -12,16 +13,16 @@ class SimpleSharedDict(shared_abstract.SharedDict): def __init__(self): self.d = {} - def get_int(self, key): + def get_int(self, key: str) -> Optional[int]: return self.d.get(key, None) - def set_int(self, key, value): + def set_int(self, key: str, value: int): self.d[key] = value - def get_str(self, key): + def get_str(self, key: str) -> Optional[str]: return self.d.get(key, None) - def set_str(self, key, value): + def set_str(self, key: str, value: str): self.d[key] = value diff --git a/searx/shared/shared_uwsgi.py b/searx/shared/shared_uwsgi.py index 592e24a4b..4a6b0a155 100644 --- a/searx/shared/shared_uwsgi.py +++ b/searx/shared/shared_uwsgi.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later import time +from typing import Optional import uwsgi # pylint: disable=E0401 from . import shared_abstract @@ -9,25 +10,25 @@ _last_signal = 10 class UwsgiCacheSharedDict(shared_abstract.SharedDict): - def get_int(self, key): + def get_int(self, key: str) -> Optional[int]: value = uwsgi.cache_get(key) if value is None: return value else: return int.from_bytes(value, 'big') - def set_int(self, key, value): + def set_int(self, key: str, value: int): b = value.to_bytes(4, 'big') uwsgi.cache_update(key, b) - def get_str(self, key): + def get_str(self, key: str) -> Optional[str]: value = uwsgi.cache_get(key) if value is None: return value else: return value.decode('utf-8') - def set_str(self, key, value): + def set_str(self, key: str, value: str): b = value.encode('utf-8') uwsgi.cache_update(key, b) -- cgit v1.2.3