diff options
| author | Dennis Fink | 2026-11-13 08:08:04 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 08:08:04 +0100 |
| commit | a227ec62b1cb0d5a4bb840072173607879e5d2f8 (patch) | |
| tree | e19e01d1481747a05432bb3acfb93d9009710ba4 /webmentions_ssg/cli.py | |
| parent | a71c9fbeb034a5a8c545c8e19679f0eb86703321 (diff) | |
| download | webmentions-ssg-a227ec62b1cb0d5a4bb840072173607879e5d2f8.tar.gz webmentions-ssg-a227ec62b1cb0d5a4bb840072173607879e5d2f8.zip | |
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.
Diffstat (limited to 'webmentions_ssg/cli.py')
| -rw-r--r-- | webmentions_ssg/cli.py | 3 |
1 files changed, 0 insertions, 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() |
