diff options
| author | Dennis Fink | 2026-11-12 22:07:12 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-12 22:07:12 +0100 |
| commit | c7993952c585b66acad5275e39dbf91cf662b975 (patch) | |
| tree | 976b3746444b3bd0bbb269bef9197c8b6a2e1696 /webmentions_ssg/cli.py | |
| parent | b930b4425b91aa42abcec6c3443685065a5ca242 (diff) | |
| download | webmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.tar.gz webmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.zip | |
chore(core): enable stricter Ruff lint rules
Expand Ruff checks for bugbear, complexity, pathlib, return statements,
simplifications, upgrades, and docstring style.
Apply the resulting behavior-neutral cleanup across application and test
code.
Diffstat (limited to 'webmentions_ssg/cli.py')
| -rw-r--r-- | webmentions_ssg/cli.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/webmentions_ssg/cli.py b/webmentions_ssg/cli.py index 0387ba6..0fed7dd 100644 --- a/webmentions_ssg/cli.py +++ b/webmentions_ssg/cli.py @@ -22,7 +22,6 @@ USERS_CLI = AppGroup("users", help="Manage users.") def _require_user(username: str): """Return a user by username or report a CLI-friendly error.""" - user = DATABASE.session.scalar(sa.select(User).where(User.username == username)) if user is None: raise click.ClickException(f"User {username!r} does not exist.") @@ -33,14 +32,12 @@ def _require_user(username: str): @click.option("--username", prompt="Username", help="Username for the new user.") @click.password_option(confirmation_prompt=True) def create_user(username: str, password: str) -> None: - """ - Create a user with a securely hashed password. + """Create a user with a securely hashed password. :param username: Username for the new user. :param password: Plain-text password to hash and store. :raises click.ClickException: If the credentials are invalid or the user exists. """ - username = username.strip() if not username: raise click.ClickException("Username must not be empty.") @@ -66,7 +63,6 @@ def create_user(username: str, password: str) -> None: @USERS_CLI.command("list", help="List registered users.") def list_users() -> None: """List user IDs and usernames in alphabetical order.""" - users = DATABASE.session.scalars(sa.select(User).order_by(User.username)).all() if not users: click.echo("No users found.") @@ -81,8 +77,7 @@ def list_users() -> None: @click.argument("username") @click.password_option(confirmation_prompt=True) def set_user_password(username: str, password: str) -> None: - """ - Change a user's password without displaying it. + """Change a user's password without displaying it. :param username: Username of the account to update. :param password: New plain-text password to hash and store. @@ -103,8 +98,7 @@ def set_user_password(username: str, password: str) -> None: @click.argument("username") @click.option("-y", "--yes", is_flag=True, help="Skip the deletion confirmation.") def delete_user(username: str, yes: bool) -> None: - """ - Permanently delete a user after confirmation, unless --yes is passed. + """Permanently delete a user after confirmation, unless --yes is passed. :param username: Username of the account to remove. :param yes: Whether to skip the confirmation prompt. @@ -127,8 +121,7 @@ MAIL_CLI = AppGroup("mail", help="Handle mail") "--to", "recipient", help="Recipient address (defaults to NOTIFICATION_EMAIL)." ) def send_test_mail(recipient: str | None) -> None: - """ - Send a test email using the configured SMTP server. + """Send a test email using the configured SMTP server. :param recipient: Optional recipient overriding NOTIFICATION_EMAIL. :raises click.ClickException: If configuration is missing or sending fails. |
