ruff: apply automatic fixes

This commit is contained in:
Jörg Thalheim
2025-08-20 13:52:45 +02:00
parent 798d445f3e
commit ea2d6aab65
217 changed files with 2283 additions and 1739 deletions

View File

@@ -27,11 +27,11 @@ def _get_user_or_default(user: str | None) -> str:
# TODO: Unify with "create clan" should be done automatically
@API.register
def create_secrets_user(
flake_dir: Path, user: str | None = None, force: bool = False
flake_dir: Path,
user: str | None = None,
force: bool = False,
) -> None:
"""
initialize sops keys for vars
"""
"""Initialize sops keys for vars"""
user = _get_user_or_default(user)
pub_keys = maybe_get_admin_public_keys()
if not pub_keys:
@@ -51,11 +51,11 @@ def _select_keys_interactive(pub_keys: list[SopsKey]) -> list[SopsKey]:
selected_keys: list[SopsKey] = []
for i, key in enumerate(pub_keys):
log.info(
f"{i + 1}: type: {key.key_type}\n pubkey: {key.pubkey}\n source: {key.source}"
f"{i + 1}: type: {key.key_type}\n pubkey: {key.pubkey}\n source: {key.source}",
)
while not selected_keys:
choice = input(
"Select keys to use (comma-separated list of numbers, or leave empty to select all): "
"Select keys to use (comma-separated list of numbers, or leave empty to select all): ",
).strip()
if not choice:
log.info("No keys selected, using all keys.")
@@ -71,11 +71,11 @@ def _select_keys_interactive(pub_keys: list[SopsKey]) -> list[SopsKey]:
def create_secrets_user_interactive(
flake_dir: Path, user: str | None = None, force: bool = False
flake_dir: Path,
user: str | None = None,
force: bool = False,
) -> None:
"""
Initialize sops keys for vars interactively.
"""
"""Initialize sops keys for vars interactively."""
user = _get_user_or_default(user)
pub_keys = maybe_get_admin_public_keys()
if pub_keys:
@@ -83,13 +83,13 @@ def create_secrets_user_interactive(
pub_keys = _select_keys_interactive(pub_keys)
else:
log.info(
"\nNo admin keys found on this machine, generating a new key for sops."
"\nNo admin keys found on this machine, generating a new key for sops.",
)
pub_keys = [generate_key()]
# make sure the user backups the generated key
log.info("\n⚠️ IMPORTANT: Secret Key Backup ⚠️")
log.info(
"The generated key above is CRITICAL for accessing your clan's secrets."
"The generated key above is CRITICAL for accessing your clan's secrets.",
)
log.info("Without this key, you will lose access to all encrypted data!")
log.info("Please backup the key file immediately to a secure location.")
@@ -97,12 +97,12 @@ def create_secrets_user_interactive(
confirm = None
while not confirm or confirm.lower() != "y":
log.info(
"\nI have backed up the key file to a secure location. Confirm [y/N]: "
"\nI have backed up the key file to a secure location. Confirm [y/N]: ",
)
confirm = input().strip().lower()
if confirm != "y":
log.error(
"You must backup the key before proceeding. This is critical for data recovery!"
"You must backup the key before proceeding. This is critical for data recovery!",
)
# persist the generated or chosen admin pubkey in the repo
@@ -115,11 +115,11 @@ def create_secrets_user_interactive(
def create_secrets_user_auto(
flake_dir: Path, user: str | None = None, force: bool = False
flake_dir: Path,
user: str | None = None,
force: bool = False,
) -> None:
"""
Detect if the user is in interactive mode or not and choose the appropriate routine.
"""
"""Detect if the user is in interactive mode or not and choose the appropriate routine."""
if sys.stdin.isatty():
create_secrets_user_interactive(
flake_dir=flake_dir,
@@ -159,7 +159,10 @@ def register_keygen_parser(parser: argparse.ArgumentParser) -> None:
)
parser.add_argument(
"-f", "--force", help="overwrite existing user", action="store_true"
"-f",
"--force",
help="overwrite existing user",
action="store_true",
)
parser.add_argument(