From e2dbb9de3392c12142c827127f405b84507dfde9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 19 Jun 2025 22:04:27 +0100 Subject: [PATCH] nixos-rebuild-ng: add string concatenation linter --- .../src/nixos_rebuild/__init__.py | 12 ++++++------ .../nixos-rebuild-ng/src/nixos_rebuild/nix.py | 2 +- .../src/nixos_rebuild/process.py | 6 +++--- .../ni/nixos-rebuild-ng/src/pyproject.toml | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py index fb68b219c1f9..2e3a321fbcd4 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py @@ -100,7 +100,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa "--attr", "-A", help="Enable and build the NixOS system from nix file and use the " - + "specified attribute path from file specified by the --file option", + "specified attribute path from file specified by the --file option", ) main_parser.add_argument( "--flake", @@ -118,7 +118,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa "--install-bootloader", action="store_true", help="Causes the boot loader to be (re)installed on the device specified " - + "by the relevant configuration options", + "by the relevant configuration options", ) main_parser.add_argument( "--install-grub", @@ -143,7 +143,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa "--upgrade", action="store_true", help="Update the root user's channel named 'nixos' before rebuilding " - + "the system and channels which have a file named '.update-on-nixos-rebuild'", + "the system and channels which have a file named '.update-on-nixos-rebuild'", ) main_parser.add_argument( "--upgrade-all", @@ -187,7 +187,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa main_parser.add_argument( "--image-variant", help="Selects an image variant to build from the " - + "config.system.build.images attribute of the given configuration", + "config.system.build.images attribute of the given configuration", ) main_parser.add_argument("action", choices=Action.values(), nargs="?") @@ -322,7 +322,7 @@ def reexec( # - Exec format error (e.g.: another OS/CPU arch) logger.warning( "could not re-exec in a newer version of nixos-rebuild, " - + "using current version", + "using current version", exc_info=logger.isEnabledFor(logging.DEBUG), ) # We already run clean-up, let's re-exec in the current version @@ -422,7 +422,7 @@ def execute(argv: list[str]) -> None: if args.image_variant not in variants: raise NRError( "please specify one of the following " - + "supported image variants via --image-variant:\n" + "supported image variants via --image-variant:\n" + "\n".join(f"- {v}" for v in variants) ) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py index 3be610b5ddbd..a55bfd508e37 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py @@ -652,7 +652,7 @@ def switch_to_configuration( if r.returncode: logger.debug( "skipping systemd-run to switch configuration since systemd is " - + "not working in target host" + "not working in target host" ) cmd = [] diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py index 462c4178e8f7..1f57111a72ef 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py @@ -55,12 +55,12 @@ class Remote: if o in ["-t", "-tt", "RequestTTY=yes", "RequestTTY=force"]: logger.warning( f"detected option '{o}' in NIX_SSHOPTS. SSH's TTY may " - + "cause issues, it is recommended to remove this option" + "cause issues, it is recommended to remove this option" ) if not ask_sudo_password: logger.warning( "if you want to prompt for sudo password use " - + "'--ask-sudo-password' option instead" + "'--ask-sudo-password' option instead" ) @@ -161,7 +161,7 @@ def run_wrapper( if sudo and remote and remote.sudo_password is None: logger.error( "while running command with remote sudo, did you forget to use " - + "--ask-sudo-password?" + "--ask-sudo-password?" ) raise diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/pyproject.toml b/pkgs/by-name/ni/nixos-rebuild-ng/src/pyproject.toml index 7874c217468d..3eb78f58e032 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/pyproject.toml +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/pyproject.toml @@ -39,37 +39,38 @@ ignore_missing_imports = true [tool.ruff.lint] extend-select = [ - # Enforce type annotations + # enforce type annotations "ANN", # don't shadow built-in names "A", - # Better list/set/dict comprehensions + # better list/set/dict comprehensions "C4", - # Check for debugger statements + # check for debugger statements "T10", # ensure imports are sorted "I", - # Automatically upgrade syntax for newer versions + # automatically upgrade syntax for newer versions "UP", # detect common sources of bugs "B", - # Ruff specific rules + # ruff specific rules "RUF", # require `check` argument for `subprocess.run` "PLW1510", # check for needless exception names in raise statements "TRY201", - # Pythonic naming conventions + # pythonic naming conventions "N", + # string concatenation rules + "ISC001", + "ISC002", + "ISC003", ] ignore = [ # allow Any type "ANN401" ] -[tool.ruff.lint.per-file-ignores] -"tests/" = ["FA102"] - [tool.pytest.ini_options] pythonpath = ["."] addopts = "--import-mode=importlib"