"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,
)
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")
)
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="?",
)
"--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,
)
) -> 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.",
)
"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
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()
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)
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",
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
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
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
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
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,
)
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()
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
) -> 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 (
) -> 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."
# 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.
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:
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)):