summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorAleš Mrázek <ales.mrazek@nic.cz>2024-10-09 22:19:31 +0200
committerAleš Mrázek <ales.mrazek@nic.cz>2024-10-17 14:39:47 +0200
commit2d90ac2dd35a49a1fff42ec5c1a9189437ab0092 (patch)
tree39bca6b7df5af8a16f47082907b493553ee13a29 /python
parentscripts/poe-tasks: use ruff instead of black, isort, pylint and flake8 (diff)
downloadknot-resolver-2d90ac2dd35a49a1fff42ec5c1a9189437ab0092.tar.xz
knot-resolver-2d90ac2dd35a49a1fff42ec5c1a9189437ab0092.zip
python: code format fixes
Diffstat (limited to 'python')
-rw-r--r--python/knot_resolver/datamodel/types/types.py12
-rw-r--r--python/knot_resolver/manager/manager.py6
-rw-r--r--python/knot_resolver/manager/metrics/prometheus.py10
-rw-r--r--python/knot_resolver/manager/server.py2
4 files changed, 16 insertions, 14 deletions
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 '<ip-address|interface-name>@<port>', 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()