]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
python: fixed too long lines (>120)
authorAleš Mrázek <ales.mrazek@nic.cz>
Sun, 11 Jan 2026 00:31:16 +0000 (01:31 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 12 Jan 2026 13:47:51 +0000 (14:47 +0100)
Ruff linter: E501 Line too long (>120)

15 files changed:
python/knot_resolver/client/commands/cache.py
python/knot_resolver/client/commands/config.py
python/knot_resolver/client/commands/convert.py
python/knot_resolver/client/commands/metrics.py
python/knot_resolver/client/commands/migrate.py
python/knot_resolver/client/commands/pids.py
python/knot_resolver/client/main.py
python/knot_resolver/datamodel/local_data_schema.py
python/knot_resolver/datamodel/network_schema.py
python/knot_resolver/datamodel/options_schema.py
python/knot_resolver/datamodel/types/base_types.py
python/knot_resolver/manager/manager.py
python/knot_resolver/manager/metrics/prometheus.py
python/knot_resolver/manager/server.py
python/knot_resolver/utils/modeling/json_pointer.py

index 09d3d0b66759f800c7b5fc6739599980ab434c8b..0fa55457b9a64b7b4a3be69aeb70d64059552756 100644 (file)
@@ -73,7 +73,8 @@ class CacheCommand(Command):
             "name",
             type=str,
             nargs="?",
-            help="Optional, subtree name to purge; if omitted, the entire cache is purged (and all other parameters are ignored).",
+            help="Optional, subtree name to purge; if omitted,"
+            " the entire cache is purged (and all other parameters are ignored).",
             default=None,
         )
 
index 090113dc4545563493eff5e7c70acda3137027d4..97b0c6725cf063575d7739fd85ab39a16d9bc3e7 100644 (file)
@@ -38,7 +38,8 @@ class ConfigCommand(Command):
         subparser: "argparse._SubParsersAction[argparse.ArgumentParser]",
     ) -> Tuple[argparse.ArgumentParser, "Type[Command]"]:
         config = subparser.add_parser("config", help="Performs operations on the running resolver's configuration.")
-        path_help = "Optional, path (JSON pointer, RFC6901) to the configuration resources. By default, the entire configuration is selected."
+        path_help = "Optional, path (JSON pointer, RFC6901) to the configuration resources. "
+        " By default, the entire configuration is selected."
 
         config_subparsers = config.add_subparsers(help="operation type")
 
@@ -56,7 +57,8 @@ class ConfigCommand(Command):
         )
         get_op.add_argument(
             "file",
-            help="Optional, path to the file where to save exported configuration data. If not specified, data will be printed.",
+            help="Optional, path to the file where to save exported configuration data."
+            " If not specified, data will be printed.",
             type=str,
             nargs="?",
         )
index 097a299976292e855e0b25391a8088c952527125..eebe1a6449e43c1694bf889fe77c0f2853932aee 100644 (file)
@@ -42,7 +42,8 @@ class ConvertCommand(Command):
             "--output",
             type=str,
             nargs="?",
-            help="Optional, output file for converted configuration in Lua script. If not specified, converted configuration is printed.",
+            help="Optional, output file for converted configuration in Lua script."
+            " If not specified, converted configuration is printed.",
             dest="output_file",
             default=None,
         )
index 2f9c9fdad6a3fa86648f3c046a6fa3491101cf9c..ffdb8697815a7397ff929ab1f0d93b9aa085a764 100644 (file)
@@ -22,7 +22,8 @@ class MetricsCommand(Command):
     ) -> Tuple[argparse.ArgumentParser, "Type[Command]"]:
         metrics = subparser.add_parser(
             "metrics",
-            help="Get aggregated metrics from the running resolver in JSON format (default) or optionally in Prometheus format."
+            help="Get aggregated metrics from the running resolver"
+            " in JSON format (default) or optionally in Prometheus format."
             "\nThe 'prometheus-client' Python package needs to be installed if you wish to use the Prometheus format."
             "\nRequires a connection to the management HTTP API.",
         )
index df8742548884ade89f0e29428dec24d25f1fd146..b0cc40fe42a3fe966d23fd52c3846e2a81d39896 100644 (file)
@@ -89,7 +89,8 @@ class MigrateCommand(Command):
             "output_file",
             type=str,
             nargs="?",
-            help="Optional, output file for migrated configuration in desired output format. If not specified, migrated configuration is printed.",
+            help="Optional, output file for migrated configuration in desired output format."
+            " If not specified, migrated configuration is printed.",
             default=None,
         )
         return migrate, MigrateCommand
@@ -98,7 +99,7 @@ class MigrateCommand(Command):
     def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
         return comp_get_words(args, parser)
 
-    def run(self, args: CommandArgs) -> None:  # noqa: PLR0912, PLR0915
+    def run(self, args: CommandArgs) -> None:  # noqa: C901, PLR0912, PLR0915
         with open(self.input_file, "r") as f:
             data = f.read()
 
index ce8d2b4f73f8f4e22f7a9ce76da7adf310b405cc..6d8b61824f517538008374d0b730c9e0e19f7228 100644 (file)
@@ -55,7 +55,8 @@ class PidsCommand(Command):
 
             else:
                 print(
-                    f"Unexpected response type '{type(processes).__name__}' from manager. Expected '{PROCESSES_TYPE.__name__}'",
+                    f"Unexpected response type '{type(processes).__name__}'"
+                    f" from manager. Expected '{PROCESSES_TYPE.__name__}'",
                     file=sys.stderr,
                 )
                 sys.exit(1)
index 683bc95b036489422d310915e1f30fcfa391ee6b..c4cf0b3e323172eb5c000822701983c8cdaa409a 100644 (file)
@@ -20,8 +20,10 @@ def auto_import_commands() -> None:
 def create_main_argument_parser() -> argparse.ArgumentParser:
     parser = argparse.ArgumentParser(
         KRES_CLIENT_NAME,
-        description="Knot Resolver command-line utility that serves as a client for communicating with the Knot Resolver management API."
-        " The utility also provides tools to work with the resolver's declarative configuration (validate, convert, ...).",
+        description="Knot Resolver command-line utility that serves as a client for"
+        " communicating with the Knot Resolver management API."
+        " The utility also provides tools to work with the resolver's"
+        " declarative configuration (validate, convert, ...).",
     )
     parser.add_argument(
         "-V",
index 5eb4bcdef697b1c7c5ca541f53cb4f135375aa62..fcb1c6827ff2920b86682a446e3c012263f93425 100644 (file)
@@ -26,7 +26,7 @@ class RuleSchema(ConfigSchema):
     tags: Tags to link with other policy rules.
     ttl: Optional, TTL value used for these answers.
     nodata: Optional, use NODATA synthesis. NODATA will be synthesized for matching name, but mismatching type(e.g. AAAA query when only A exists).
-    """
+    """  # noqa: E501
 
     name: Optional[ListOrItem[DomainName]] = None
     subtree: Optional[Literal["empty", "nxdomain", "redirect"]] = None
@@ -105,7 +105,7 @@ class LocalDataSchema(ConfigSchema):
     records: Direct addition of records in DNS zone file format.
     rules: Local data rules.
     rpz: List of Response Policy Zones and its configuration.
-    """
+    """  # noqa: E501
 
     ttl: Optional[TimeUnit] = None
     nodata: bool = True
index aada989cf82db9342a3587b17565de3242a44e6c..e3011bcd20faabab6753147bbe76c7f4e92aab61 100644 (file)
@@ -185,7 +185,7 @@ class NetworkSchema(ConfigSchema):
     tls: TLS configuration, also affects DNS over TLS and DNS over HTTPS.
     proxy_protocol: PROXYv2 protocol configuration.
     listen: List of interfaces to listen to and its configuration.
-    """
+    """  # noqa: E501
 
     do_ipv4: bool = True
     do_ipv6: bool = True
index 6370a6e2f356867b68d1c868e88d3eb55cb83204..b5eaf78b8033076673a2570b427fe6546f97a9a7 100644 (file)
@@ -21,7 +21,7 @@ class OptionsSchema(ConfigSchema):
     time_jump_detection: Detection of difference between local system time and expiration time bounds in DNSSEC signatures for '. NS' records.
     violators_workarounds: Workarounds for known DNS protocol violators.
     serve_stale: Allows using timed-out records in case DNS resolver is unable to contact upstream servers.
-    """
+    """  # noqa: E501
 
     glue_checking: GlueCheckingEnum = "normal"
     minimize: bool = True
index a975971c936219e411b43f43dfe678426837713b..c034fdb8523307e3cc25292064705ae6a3b8382f 100644 (file)
@@ -274,7 +274,8 @@ class UnitBase(StrBase):
         else:
             raise ValueError(
                 f"Unexpected value for '{type(self)}'."
-                " Expected string that matches pattern " + rf"'{type(self)._re.pattern}'."
+                " Expected string that matches pattern "
+                rf"'{type(self)._re.pattern}'."
                 f" Positive integer and one of the units {list(type(self)._units.keys())}, got '{source_value}'.",
                 object_path,
             )
index ce5919e4cdd59d097a829d9a4294d95ee2bedc4d..8d956bdc76895dc0603ea6cb6aca1a78835ef363 100644 (file)
@@ -39,7 +39,8 @@ class _FixCounter:
     def try_decrease(self) -> None:
         if time.time() - self._timestamp > FIX_COUNTER_DECREASE_INTERVAL_SEC and self._counter > 0:
             logger.info(
-                f"Enough time has passed since last detected instability, decreasing fix attempt counter to {self._counter}"
+                "Enough time has passed since last detected instability,"
+                f" decreasing fix attempt counter to {self._counter}"
             )
             self._counter -= 1
             self._timestamp = time.time()
@@ -425,7 +426,8 @@ class KresManager:  # pylint: disable=too-many-instance-attributes
                     if detected_subprocesses[eid] is SubprocessStatus.FATAL:
                         if self._policy_loader and self._policy_loader.id == eid:
                             logger.info(
-                                "Subprocess '%s' is skipped by WatchDog because its status is monitored in a different way.",
+                                "Subprocess '%s' is skipped by WatchDog"
+                                " because its status is monitored in a different way.",
                                 eid,
                             )
                             continue
index 4e2431665bff37a5084f9df5fed8402278d63682..dd92ce9b632d7204fc8d8d8323265bf892643a13 100644 (file)
@@ -422,7 +422,8 @@ if PROMETHEUS_LIB:
     ) -> Result[None, str]:
         if old_config.monitoring.graphite.enable and not new_config.monitoring.graphite.enable:
             return Result.err(
-                "You can't turn off graphite monitoring dynamically. If you really want this feature, please let the developers know."
+                "You can't turn off graphite monitoring dynamically."
+                " If you really want this feature, please let the developers know."
             )
 
         if (
index f86fada98872bffafce3db1b657674669d7bc4f1..384b9d9eba50ae7432e51fa1609fc9ef0422e46a 100644 (file)
@@ -110,7 +110,7 @@ class Server:
     ) -> Result[None, str]:
         if config_old.management != config_new.management:
             return Result.err(
-                "/server/management: Changing management API address/unix-socket dynamically is not allowed as it's really dangerous."
+                "/management: Changing the management API configuration dynamically is not allowed."
                 " If you really need this feature, please contact the developers and explain why. Technically,"
                 " there are no problems in supporting it. We are only blocking the dynamic changes because"
                 " we think the consequences of leaving this footgun unprotected are worse than its usefulness."
@@ -603,7 +603,8 @@ async def start_server(config: List[str]) -> int:  # noqa: PLR0915
         # After the working directory is set, we can initialize proper config store with a newly parsed configuration.
         config_store = await _init_config_store(config_data)
 
-        # Some "constants" need to be loaded from the initial config, some need to be stored from the initial run conditions
+        # Some "constants" need to be loaded from the initial config,
+        # some need to be stored from the initial run conditions
         await init_user_constants(config_store, working_directory_on_startup)
 
         # This behaviour described above with paths means, that we MUST NOT allow `rundir` change after initialization.
index 2ced30e70e73ee495f7485baa32211dec992ddc1..c9bfc3538eaa26e3d136ab455a78b63c56d81931 100644 (file)
@@ -2,8 +2,7 @@
 
 from typing import Any, Optional, Tuple, Union
 
-# JSONPtrAddressable = Optional[Union[Dict[str, "JSONPtrAddressable"], List["JSONPtrAddressable"], int, float, bool, str, None]]
-JSONPtrAddressable = Any  # the recursive definition above is not valid :(
+JSONPtrAddressable = Any
 
 
 class _JSONPtr:
@@ -43,7 +42,8 @@ class _JSONPtr:
         for token in self.tokens:
             if current is None:
                 raise ValueError(
-                    f"JSON pointer cannot reference nested non-existent object: object at ptr '{current_ptr}' already points to None, cannot nest deeper with token '{token}'"
+                    f"JSON pointer cannot reference nested non-existent object: object at ptr '{current_ptr}'"
+                    f" already points to None, cannot nest deeper with token '{token}'"
                 )
 
             if isinstance(current, (bool, int, float, str)):