Skip to content

Commit 6b42ec6

Browse files
committed
Applied reformat
1 parent ce933b8 commit 6b42ec6

9 files changed

+53
-19
lines changed

backend/app/alembic/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Alembic configuration for database migrations."""
2+
23
from logging.config import fileConfig
34

45
from alembic import context

backend/app/alembic/versions/1a31ce608336_add_cascade_delete_relationships.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ def upgrade() -> None:
2020
"""Upgrade database schema."""
2121
# ### commands auto generated by Alembic - please adjust! ###
2222
op.alter_column(
23-
"item", "owner_id", existing_type=sa.UUID(), nullable=False,
23+
"item",
24+
"owner_id",
25+
existing_type=sa.UUID(),
26+
nullable=False,
2427
)
2528
op.drop_constraint("item_owner_id_fkey", "item", type_="foreignkey")
2629
op.create_foreign_key(
27-
None, "item", "user", ["owner_id"], ["id"], ondelete="CASCADE",
30+
None,
31+
"item",
32+
"user",
33+
["owner_id"],
34+
["id"],
35+
ondelete="CASCADE",
2836
)
2937
# ### end Alembic commands ###
3038

@@ -34,7 +42,11 @@ def downgrade() -> None:
3442
# ### commands auto generated by Alembic - please adjust! ###
3543
op.drop_constraint("item_owner_id_fkey", "item", type_="foreignkey")
3644
op.create_foreign_key(
37-
"item_owner_id_fkey", "item", "user", ["owner_id"], ["id"],
45+
"item_owner_id_fkey",
46+
"item",
47+
"user",
48+
["owner_id"],
49+
["id"],
3850
)
3951
op.alter_column("item", "owner_id", existing_type=sa.UUID(), nullable=True)
4052
# ### end Alembic commands ###

backend/app/alembic/versions/d98dd8ec85a3_edit_replace_id_integers_in_all_models_.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ def upgrade() -> None:
4242
op.add_column(
4343
"item",
4444
sa.Column(
45-
"new_owner_id", postgresql.UUID(as_uuid=True), nullable=True,
45+
"new_owner_id",
46+
postgresql.UUID(as_uuid=True),
47+
nullable=True,
4648
),
4749
)
4850

4951
# Populate the new columns with UUIDs
5052
op.execute('UPDATE "user" SET new_id = uuid_generate_v4()')
5153
op.execute("UPDATE item SET new_id = uuid_generate_v4()")
5254
op.execute(
53-
'UPDATE item SET new_owner_id = '
55+
"UPDATE item SET new_owner_id = "
5456
'(SELECT new_id FROM "user" WHERE "user".id = item.owner_id)',
5557
)
5658

@@ -75,7 +77,11 @@ def upgrade() -> None:
7577

7678
# Recreate foreign key constraint
7779
op.create_foreign_key(
78-
"item_owner_id_fkey", "item", "user", ["owner_id"], ["id"],
80+
"item_owner_id_fkey",
81+
"item",
82+
"user",
83+
["owner_id"],
84+
["id"],
7985
)
8086

8187

@@ -89,12 +95,10 @@ def downgrade() -> None:
8995
# Populate the old columns with default values
9096
# Generate sequences for the integer IDs if not exist
9197
op.execute(
92-
'CREATE SEQUENCE IF NOT EXISTS user_id_seq AS INTEGER '
93-
'OWNED BY "user".old_id',
98+
'CREATE SEQUENCE IF NOT EXISTS user_id_seq AS INTEGER OWNED BY "user".old_id',
9499
)
95100
op.execute(
96-
"CREATE SEQUENCE IF NOT EXISTS item_id_seq AS INTEGER "
97-
"OWNED BY item.old_id",
101+
"CREATE SEQUENCE IF NOT EXISTS item_id_seq AS INTEGER OWNED BY item.old_id",
98102
)
99103

100104
op.execute(
@@ -108,7 +112,7 @@ def downgrade() -> None:
108112

109113
op.execute("UPDATE \"user\" SET old_id = nextval('user_id_seq')")
110114
op.execute(
111-
'UPDATE item SET old_id = nextval(\'item_id_seq\'), '
115+
"UPDATE item SET old_id = nextval('item_id_seq'), "
112116
'old_owner_id = (SELECT old_id FROM "user" '
113117
'WHERE "user".id = item.owner_id)',
114118
)
@@ -130,5 +134,9 @@ def downgrade() -> None:
130134

131135
# Recreate foreign key constraint
132136
op.create_foreign_key(
133-
"item_owner_id_fkey", "item", "user", ["owner_id"], ["id"],
137+
"item_owner_id_fkey",
138+
"item",
139+
"user",
140+
["owner_id"],
141+
["id"],
134142
)

backend/app/alembic/versions/e2412789c190_initialize_models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def upgrade() -> None:
2626
sa.Column("is_active", sa.Boolean(), nullable=False),
2727
sa.Column("is_superuser", sa.Boolean(), nullable=False),
2828
sa.Column(
29-
"full_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True,
29+
"full_name",
30+
sqlmodel.sql.sqltypes.AutoString(),
31+
nullable=True,
3032
),
3133
sa.Column("id", sa.Integer(), nullable=False),
3234
sa.Column(
@@ -40,7 +42,9 @@ def upgrade() -> None:
4042
op.create_table(
4143
"item",
4244
sa.Column(
43-
"description", sqlmodel.sql.sqltypes.AutoString(), nullable=True,
45+
"description",
46+
sqlmodel.sql.sqltypes.AutoString(),
47+
nullable=True,
4448
),
4549
sa.Column("id", sa.Integer(), nullable=False),
4650
sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=False),

backend/app/api/routes/items.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ def read_items(
4646

4747
@router.get("/{item_id}")
4848
def read_item(
49-
session: SessionDep, current_user: CurrentUser, item_id: uuid.UUID,
49+
session: SessionDep,
50+
current_user: CurrentUser,
51+
item_id: uuid.UUID,
5052
) -> ItemPublic:
5153
"""Get item by ID."""
5254
db_item = session.get(Item, item_id)
5355
if not db_item:
5456
raise HTTPException(status_code=NOT_FOUND_CODE, detail="Item not found")
5557
if not current_user.is_superuser and (db_item.owner_id != current_user.id):
5658
raise HTTPException(
57-
status_code=BAD_REQUEST_CODE, detail="Not enough permissions",
59+
status_code=BAD_REQUEST_CODE,
60+
detail="Not enough permissions",
5861
)
5962
return ItemPublic.model_validate(db_item)
6063

@@ -88,7 +91,8 @@ def update_item(
8891
raise HTTPException(status_code=NOT_FOUND_CODE, detail="Item not found")
8992
if not current_user.is_superuser and (db_item.owner_id != current_user.id):
9093
raise HTTPException(
91-
status_code=BAD_REQUEST_CODE, detail="Not enough permissions",
94+
status_code=BAD_REQUEST_CODE,
95+
detail="Not enough permissions",
9296
)
9397
update_dict = item_in.model_dump(exclude_unset=True)
9498
db_item.sqlmodel_update(update_dict)
@@ -110,7 +114,8 @@ def delete_item(
110114
raise HTTPException(status_code=NOT_FOUND_CODE, detail="Item not found")
111115
if not current_user.is_superuser and (db_item.owner_id != current_user.id):
112116
raise HTTPException(
113-
status_code=BAD_REQUEST_CODE, detail="Not enough permissions",
117+
status_code=BAD_REQUEST_CODE,
118+
detail="Not enough permissions",
114119
)
115120
session.delete(db_item)
116121
session.commit()

backend/app/api/routes/login.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def login_access_token(
3636
)
3737
if not user:
3838
raise HTTPException(
39-
status_code=BAD_REQUEST_CODE, detail="Incorrect email or password",
39+
status_code=BAD_REQUEST_CODE,
40+
detail="Incorrect email or password",
4041
)
4142
if not user.is_active:
4243
raise HTTPException(status_code=BAD_REQUEST_CODE, detail="Inactive user")

backend/app/backend_pre_start.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Backend pre-start script to ensure database connectivity."""
2+
23
import logging
34

45
from sqlalchemy import Engine

backend/app/email_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utility functions for email, authentication, and template rendering."""
2+
23
import logging
34
from dataclasses import dataclass
45
from datetime import UTC, datetime, timedelta

backend/app/tests_pre_start.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Pre-start tests to ensure database connectivity."""
2+
23
import logging
34

45
from sqlalchemy import Engine

0 commit comments

Comments
 (0)