From 2d90ac2dd35a49a1fff42ec5c1a9189437ab0092 Mon Sep 17 00:00:00 2001 From: Aleš Mrázek Date: Wed, 9 Oct 2024 22:19:31 +0200 Subject: python: code format fixes --- python/knot_resolver/datamodel/types/types.py | 12 ++++++------ python/knot_resolver/manager/manager.py | 6 +++--- python/knot_resolver/manager/metrics/prometheus.py | 10 +++++++--- python/knot_resolver/manager/server.py | 2 -- 4 files changed, 16 insertions(+), 14 deletions(-) (limited to 'python') diff --git a/python/knot_resolver/datamodel/types/types.py b/python/knot_resolver/datamodel/types/types.py index 1a125720..dc3227fd 100644 --- a/python/knot_resolver/datamodel/types/types.py +++ b/python/knot_resolver/datamodel/types/types.py @@ -208,9 +208,9 @@ class InterfacePort(StrBase): try: self.if_name = InterfaceName(parts[0]) except ValueError as e2: - raise ValueError( - f"expected IP address or interface name, got '{parts[0]}'.", object_path - ) from e1 and e2 + raise ValueError(f"expected IP address or interface name, got '{parts[0]}'.", object_path) from ( + e1 and e2 + ) self.port = PortNumber.from_str(parts[1], object_path) else: raise ValueError(f"expected '@', got '{source_value}'.", object_path) @@ -232,9 +232,9 @@ class InterfaceOptionalPort(StrBase): try: self.if_name = InterfaceName(parts[0]) except ValueError as e2: - raise ValueError( - f"expected IP address or interface name, got '{parts[0]}'.", object_path - ) from e1 and e2 + raise ValueError(f"expected IP address or interface name, got '{parts[0]}'.", object_path) from ( + e1 and e2 + ) if len(parts) == 2: self.port = PortNumber.from_str(parts[1], object_path) else: diff --git a/python/knot_resolver/manager/manager.py b/python/knot_resolver/manager/manager.py index 74d90ec3..e8be4001 100644 --- a/python/knot_resolver/manager/manager.py +++ b/python/knot_resolver/manager/manager.py @@ -233,7 +233,6 @@ class KresManager: # pylint: disable=too-many-instance-attributes await self._collect_already_running_workers() async def reset_workers_policy_rules(self, _config: KresConfig) -> None: - # command all running 'kresd' workers to reset their old policy rules, # unless the workers have already been started with a new config so reset is not needed if self._workers_reset_needed and get_registered_workers_kresids(): @@ -249,7 +248,6 @@ class KresManager: # pylint: disable=too-many-instance-attributes ) async def set_new_tls_sticket_secret(self, config: KresConfig) -> None: - if config.network.tls.sticket_secret or config.network.tls.sticket_secret_file: logger.debug("User-configured TLS resumption secret found - skipping auto-generation.") return @@ -282,7 +280,9 @@ class KresManager: # pylint: disable=too-many-instance-attributes elif self._fix_counter.is_too_high(): logger.error(f"Failed to apply config: {e}") logger.error("There have already been problems recently, refusing to try to fix it.") - await self.forced_shutdown() # possible improvement - the person who requested this change won't get a response this way + await ( + self.forced_shutdown() + ) # possible improvement - the person who requested this change won't get a response this way else: logger.error(f"Failed to apply config: {e}") logger.warning("Reloading system state and trying again.") diff --git a/python/knot_resolver/manager/metrics/prometheus.py b/python/knot_resolver/manager/metrics/prometheus.py index ba5f6334..dbdb0810 100644 --- a/python/knot_resolver/manager/metrics/prometheus.py +++ b/python/knot_resolver/manager/metrics/prometheus.py @@ -19,11 +19,15 @@ if importlib.util.find_spec("prometheus_client"): logger = logging.getLogger(__name__) if _prometheus_client: - from prometheus_client import exposition # type: ignore from prometheus_client.bridge.graphite import GraphiteBridge # type: ignore - from prometheus_client.core import GaugeMetricFamily # type: ignore - from prometheus_client.core import REGISTRY, CounterMetricFamily, HistogramMetricFamily, Metric + from prometheus_client.core import ( + REGISTRY, + CounterMetricFamily, + GaugeMetricFamily, # type: ignore + HistogramMetricFamily, + Metric, + ) _graphite_bridge: Optional[GraphiteBridge] = None diff --git a/python/knot_resolver/manager/server.py b/python/knot_resolver/manager/server.py index 18a2aebc..bc75c882 100644 --- a/python/knot_resolver/manager/server.py +++ b/python/knot_resolver/manager/server.py @@ -241,7 +241,6 @@ class Server: raise web.HTTPMovedPermanently("/metrics/json") async def _handler_metrics_json(self, _request: web.Request) -> web.Response: - config = self.config_store.get() return web.Response( @@ -251,7 +250,6 @@ class Server: ) async def _handler_metrics_prometheus(self, _request: web.Request) -> web.Response: - metrics_report = await metrics.report_prometheus() if not metrics_report: raise web.HTTPNotFound() -- cgit v1.2.3