Skip to content

Commit

Permalink
Fix linting, use new query syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrillkuettel committed May 15, 2024
1 parent 69f81b9 commit a1eea2a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/privatim/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import os
import click
from privatim.cli.add_user import add_user
from privatim.utils import first




@click.group()
Expand All @@ -14,7 +10,5 @@ def cli() -> None:
cli.add_command(add_user)




if __name__ == '__main__':
cli()
4 changes: 3 additions & 1 deletion src/privatim/cli/add_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click
from pyramid.paster import bootstrap
from pyramid.paster import get_appsettings
from sqlalchemy import select

from privatim.models import User
from privatim.orm import get_engine, Base
Expand All @@ -20,7 +21,8 @@ def add_user(config_uri: str, email: str, password: str) -> None:
with env['request'].tm:
dbsession = env['request'].dbsession

existing_user = dbsession.query(User).filter(User.email == email).first()
query = select(User).filter(User.email == email)
existing_user = dbsession.execute(query).scalar_one_or_none()
if existing_user:
click.echo(f"User with email {email} already exists.")
return
Expand Down
2 changes: 0 additions & 2 deletions src/privatim/cli/find_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import TYPE_CHECKING
import os
import click
from privatim.utils import first

if TYPE_CHECKING:
from typing import Iterator
Expand Down Expand Up @@ -67,4 +66,3 @@ def find_ini_file_or_abort() -> str:

click.echo('No suitable .ini file found. Aborting.')
click.get_current_context().abort()

2 changes: 0 additions & 2 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from privatim.cli.find_files import find_ini_files
from tests.shared.fixtures import temporary_directory
from pathlib import Path
Expand All @@ -21,4 +20,3 @@ def test_find_ini_files(temporary_directory):
assert file__.exists()
file = next(find_ini_files(str(file__)))
assert 'development.ini' in file

0 comments on commit a1eea2a

Please sign in to comment.