From: Aleš Mrázek Date: Mon, 19 Feb 2024 15:25:56 +0000 (+0100) Subject: lint: fixes for new versions of tools X-Git-Tag: v6.0.7~20^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d1bfc46e681fd1840701e35e8a01436df913de0;p=thirdparty%2Fknot-resolver.git lint: fixes for new versions of tools --- diff --git a/manager/knot_resolver_manager/cli/command.py b/manager/knot_resolver_manager/cli/command.py index ba490e47e..e2f6811fe 100644 --- a/manager/knot_resolver_manager/cli/command.py +++ b/manager/knot_resolver_manager/cli/command.py @@ -40,7 +40,7 @@ def install_commands_parsers(parser: argparse.ArgumentParser) -> None: def get_socket_from_config(config: Path, optional_file: bool) -> Optional[SocketDesc]: try: - with open(config, "r") as f: + with open(config, "r", encoding="utf8") as f: data = parsing.try_to_parse(f.read()) mkey = "management" if mkey in data: diff --git a/manager/knot_resolver_manager/compat/asyncio.py b/manager/knot_resolver_manager/compat/asyncio.py index d98f06c16..9e10e6c64 100644 --- a/manager/knot_resolver_manager/compat/asyncio.py +++ b/manager/knot_resolver_manager/compat/asyncio.py @@ -91,7 +91,7 @@ def _cancel_all_tasks(loop: AbstractEventLoop) -> None: # Backported from: # https://github.com/python/cpython/blob/3.9/Lib/asyncio/runners.py#L55-L74 # - to_cancel = tasks.Task.all_tasks(loop) + to_cancel = tasks.all_tasks(loop) if not to_cancel: return @@ -103,7 +103,7 @@ def _cancel_all_tasks(loop: AbstractEventLoop) -> None: # since 3.10, the loop argument is removed loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True)) else: - loop.run_until_complete(tasks.gather(*to_cancel, loop=loop, return_exceptions=True)) + loop.run_until_complete(tasks.gather(*to_cancel, loop=loop, return_exceptions=True)) # type: ignore[call-overload] for task in to_cancel: if task.cancelled(): diff --git a/manager/knot_resolver_manager/compat/dataclasses.py b/manager/knot_resolver_manager/compat/dataclasses.py index 440b34c8a..f420b03dc 100644 --- a/manager/knot_resolver_manager/compat/dataclasses.py +++ b/manager/knot_resolver_manager/compat/dataclasses.py @@ -2,7 +2,6 @@ This module contains rather simplistic reimplementation of dataclasses due to them being unsupported on Python 3.6 """ - from typing import Any, Dict, Set, Type dataclasses_import_success = False diff --git a/manager/knot_resolver_manager/datamodel/forward_schema.py b/manager/knot_resolver_manager/datamodel/forward_schema.py index 25168ce52..8b4254265 100644 --- a/manager/knot_resolver_manager/datamodel/forward_schema.py +++ b/manager/knot_resolver_manager/datamodel/forward_schema.py @@ -26,7 +26,7 @@ class ForwardServerSchema(ConfigSchema): def _validate(self) -> None: if self.pin_sha256 and (self.hostname or self.ca_file): - ValueError("'pin-sha256' cannot be configurad together with 'hostname' or 'ca-file'") + raise ValueError("'pin-sha256' cannot be configurad together with 'hostname' or 'ca-file'") class ForwardOptionsSchema(ConfigSchema): diff --git a/manager/knot_resolver_manager/kresd_controller/__init__.py b/manager/knot_resolver_manager/kresd_controller/__init__.py index 6c5053e2c..a21bc44cd 100644 --- a/manager/knot_resolver_manager/kresd_controller/__init__.py +++ b/manager/knot_resolver_manager/kresd_controller/__init__.py @@ -5,6 +5,7 @@ from imports, they are located in functions which are invoked at the end of this We supported multiple subprocess controllers while developing it. It now all converged onto just supervisord. The interface however remains so that different controllers can be added in the future. """ + # pylint: disable=import-outside-toplevel import asyncio diff --git a/manager/knot_resolver_manager/kresd_controller/interface.py b/manager/knot_resolver_manager/kresd_controller/interface.py index 77197a320..1dc99505f 100644 --- a/manager/knot_resolver_manager/kresd_controller/interface.py +++ b/manager/knot_resolver_manager/kresd_controller/interface.py @@ -12,9 +12,8 @@ from weakref import WeakValueDictionary from knot_resolver_manager.constants import kresd_config_file from knot_resolver_manager.datamodel.config_schema import KresConfig from knot_resolver_manager.exceptions import SubprocessControllerException -from knot_resolver_manager.utils.async_utils import writefile - from knot_resolver_manager.kresd_controller.registered_workers import register_worker, unregister_worker +from knot_resolver_manager.utils.async_utils import writefile logger = logging.getLogger(__name__) diff --git a/manager/knot_resolver_manager/main.py b/manager/knot_resolver_manager/main.py index 5cbc7f28a..9428c880e 100644 --- a/manager/knot_resolver_manager/main.py +++ b/manager/knot_resolver_manager/main.py @@ -10,7 +10,7 @@ from pathlib import Path from typing import NoReturn from knot_resolver_manager import compat -from knot_resolver_manager.constants import DEFAULT_MANAGER_CONFIG_FILE, CONFIG_FILE_ENV_VAR +from knot_resolver_manager.constants import CONFIG_FILE_ENV_VAR, DEFAULT_MANAGER_CONFIG_FILE from knot_resolver_manager.log import logger_startup from knot_resolver_manager.server import start_server diff --git a/manager/knot_resolver_manager/utils/modeling/json_pointer.py b/manager/knot_resolver_manager/utils/modeling/json_pointer.py index 6d7c9e397..a60ba5d1e 100644 --- a/manager/knot_resolver_manager/utils/modeling/json_pointer.py +++ b/manager/knot_resolver_manager/utils/modeling/json_pointer.py @@ -3,7 +3,6 @@ Implements JSON pointer resolution based on RFC 6901: https://www.rfc-editor.org/rfc/rfc6901 """ - from typing import Any, Optional, Tuple, Union # JSONPtrAddressable = Optional[Union[Dict[str, "JSONPtrAddressable"], List["JSONPtrAddressable"], int, float, bool, str, None]]