From a227ec62b1cb0d5a4bb840072173607879e5d2f8 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 08:08:04 +0100 Subject: refactor(core): use EAFP for user creation Rely on the database uniqueness constraint and existing `IntegrityError` handling instead of performing a redundant pre-insert user lookup. --- webmentions_ssg/cli.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/webmentions_ssg/cli.py b/webmentions_ssg/cli.py index b0459d4..7a68651 100644 --- a/webmentions_ssg/cli.py +++ b/webmentions_ssg/cli.py @@ -47,9 +47,6 @@ def create_user(username: str, password: str) -> None: except ValueError as exc: raise click.ClickException(str(exc)) from exc - if db.session.scalar(sa.select(User).where(User.username == username)): - raise click.ClickException(f"User {username!r} already exists.") - db.session.add(User(username=username, password=password)) try: db.session.commit() -- cgit v1.3.1