[refactor] add type hints & remove Setting._post_init

Previously the Setting classes used a horrible _post_init
hack that prevented proper type checking.
This commit is contained in:
Martin Fischer 2022-01-04 11:53:42 +01:00
parent 93c6829b27
commit bb06758a7b
4 changed files with 133 additions and 139 deletions

View file

@ -10,10 +10,20 @@ from os.path import abspath, basename, dirname, exists, join
from shutil import copyfile
from pkgutil import iter_modules
from logging import getLogger
from typing import List
from searx import logger, settings
class Plugin: # pylint: disable=too-few-public-methods
"""This class is currently never initialized and only used for type hinting."""
id: str
name: str
description: str
default_on: bool
logger = logger.getChild("plugins")
required_attrs = (
@ -175,7 +185,7 @@ def load_and_initialize_plugin(plugin_module_name, external, init_args):
class PluginStore:
def __init__(self):
self.plugins = []
self.plugins: List[Plugin] = []
def __iter__(self):
for plugin in self.plugins: