From: Aleš Mrázek Date: Sun, 11 Jan 2026 00:31:16 +0000 (+0100) Subject: python: fixed too long lines (>120) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36aaec70b56d572c29a24dd478a0688dac7a1bfe;p=thirdparty%2Fknot-resolver.git python: fixed too long lines (>120) Ruff linter: E501 Line too long (>120) --- diff --git a/python/knot_resolver/client/commands/cache.py b/python/knot_resolver/client/commands/cache.py index 09d3d0b66..0fa55457b 100644 --- a/python/knot_resolver/client/commands/cache.py +++ b/python/knot_resolver/client/commands/cache.py @@ -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, ) diff --git a/python/knot_resolver/client/commands/config.py b/python/knot_resolver/client/commands/config.py index 090113dc4..97b0c6725 100644 --- a/python/knot_resolver/client/commands/config.py +++ b/python/knot_resolver/client/commands/config.py @@ -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="?", ) diff --git a/python/knot_resolver/client/commands/convert.py b/python/knot_resolver/client/commands/convert.py index 097a29997..eebe1a644 100644 --- a/python/knot_resolver/client/commands/convert.py +++ b/python/knot_resolver/client/commands/convert.py @@ -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, ) diff --git a/python/knot_resolver/client/commands/metrics.py b/python/knot_resolver/client/commands/metrics.py index 2f9c9fdad..ffdb86978 100644 --- a/python/knot_resolver/client/commands/metrics.py +++ b/python/knot_resolver/client/commands/metrics.py @@ -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.", ) diff --git a/python/knot_resolver/client/commands/migrate.py b/python/knot_resolver/client/commands/migrate.py index df8742548..b0cc40fe4 100644 --- a/python/knot_resolver/client/commands/migrate.py +++ b/python/knot_resolver/client/commands/migrate.py @@ -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() diff --git a/python/knot_resolver/client/commands/pids.py b/python/knot_resolver/client/commands/pids.py index ce8d2b4f7..6d8b61824 100644 --- a/python/knot_resolver/client/commands/pids.py +++ b/python/knot_resolver/client/commands/pids.py @@ -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) diff --git a/python/knot_resolver/client/main.py b/python/knot_resolver/client/main.py index 683bc95b0..c4cf0b3e3 100644 --- a/python/knot_resolver/client/main.py +++ b/python/knot_resolver/client/main.py @@ -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", diff --git a/python/knot_resolver/datamodel/local_data_schema.py b/python/knot_resolver/datamodel/local_data_schema.py index 5eb4bcdef..fcb1c6827 100644 --- a/python/knot_resolver/datamodel/local_data_schema.py +++ b/python/knot_resolver/datamodel/local_data_schema.py @@ -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 diff --git a/python/knot_resolver/datamodel/network_schema.py b/python/knot_resolver/datamodel/network_schema.py index aada989cf..e3011bcd2 100644 --- a/python/knot_resolver/datamodel/network_schema.py +++ b/python/knot_resolver/datamodel/network_schema.py @@ -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 diff --git a/python/knot_resolver/datamodel/options_schema.py b/python/knot_resolver/datamodel/options_schema.py index 6370a6e2f..b5eaf78b8 100644 --- a/python/knot_resolver/datamodel/options_schema.py +++ b/python/knot_resolver/datamodel/options_schema.py @@ -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 diff --git a/python/knot_resolver/datamodel/types/base_types.py b/python/knot_resolver/datamodel/types/base_types.py index a975971c9..c034fdb85 100644 --- a/python/knot_resolver/datamodel/types/base_types.py +++ b/python/knot_resolver/datamodel/types/base_types.py @@ -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, ) diff --git a/python/knot_resolver/manager/manager.py b/python/knot_resolver/manager/manager.py index ce5919e4c..8d956bdc7 100644 --- a/python/knot_resolver/manager/manager.py +++ b/python/knot_resolver/manager/manager.py @@ -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 diff --git a/python/knot_resolver/manager/metrics/prometheus.py b/python/knot_resolver/manager/metrics/prometheus.py index 4e2431665..dd92ce9b6 100644 --- a/python/knot_resolver/manager/metrics/prometheus.py +++ b/python/knot_resolver/manager/metrics/prometheus.py @@ -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 ( diff --git a/python/knot_resolver/manager/server.py b/python/knot_resolver/manager/server.py index f86fada98..384b9d9eb 100644 --- a/python/knot_resolver/manager/server.py +++ b/python/knot_resolver/manager/server.py @@ -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. diff --git a/python/knot_resolver/utils/modeling/json_pointer.py b/python/knot_resolver/utils/modeling/json_pointer.py index 2ced30e70..c9bfc3538 100644 --- a/python/knot_resolver/utils/modeling/json_pointer.py +++ b/python/knot_resolver/utils/modeling/json_pointer.py @@ -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)):