Skip to content

Commit 72edb24

Browse files
committed
Fixed mypy errors
1 parent 6668adf commit 72edb24

30 files changed

+467
-409
lines changed

.copier/.copier-answers.yml.jinja

Lines changed: 0 additions & 1 deletion
This file was deleted.

.copier/update_dotenv.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

backend/app/alembic/env.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from logging.config import fileConfig
32

43
from alembic import context
@@ -10,30 +9,21 @@
109

1110
# Interpret the config file for Python logging.
1211
# This line sets up loggers basically.
13-
fileConfig(config.config_file_name)
12+
if config.config_file_name:
13+
fileConfig(config.config_file_name)
1414

15-
# add your model's MetaData object here
16-
# for 'autogenerate' support
17-
# from myapp import mymodel
18-
# target_metadata = mymodel.Base.metadata
19-
# target_metadata = None
2015

21-
from app.models import SQLModel # noqa
22-
from app.core.config import settings # noqa
16+
from app.core.config import settings # noqa
17+
from sqlmodel import SQLModel
2318

2419
target_metadata = SQLModel.metadata
2520

26-
# other values from the config, defined by the needs of env.py,
27-
# can be acquired:
28-
# my_important_option = config.get_main_option("my_important_option")
29-
# ... etc.
3021

31-
32-
def get_url():
22+
def get_url() -> str:
3323
return str(settings.SQLALCHEMY_DATABASE_URI)
3424

3525

36-
def run_migrations_offline():
26+
def run_migrations_offline() -> None:
3727
"""Run migrations in 'offline' mode.
3828
3929
This configures the context with just a URL
@@ -47,21 +37,24 @@ def run_migrations_offline():
4737
"""
4838
url = get_url()
4939
context.configure(
50-
url=url, target_metadata=target_metadata, literal_binds=True, compare_type=True
40+
url=url,
41+
target_metadata=target_metadata,
42+
literal_binds=True,
43+
compare_type=True,
5144
)
5245

5346
with context.begin_transaction():
5447
context.run_migrations()
5548

5649

57-
def run_migrations_online():
50+
def run_migrations_online() -> None:
5851
"""Run migrations in 'online' mode.
5952
6053
In this scenario we need to create an Engine
6154
and associate a connection with the context.
6255
6356
"""
64-
configuration = config.get_section(config.config_ini_section)
57+
configuration = config.get_section(config.config_ini_section) or {}
6558
configuration["sqlalchemy.url"] = get_url()
6659
connectable = engine_from_config(
6760
configuration,
@@ -71,7 +64,9 @@ def run_migrations_online():
7164

7265
with connectable.connect() as connection:
7366
context.configure(
74-
connection=connection, target_metadata=target_metadata, compare_type=True
67+
connection=connection,
68+
target_metadata=target_metadata,
69+
compare_type=True,
7570
)
7671

7772
with context.begin_transaction():

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,30 @@
55
Create Date: 2024-07-31 22:24:34.447891
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
10-
import sqlmodel.sql.sqltypes
118

9+
import sqlalchemy as sa
10+
from alembic import op
1211

1312
# revision identifiers, used by Alembic.
14-
revision = '1a31ce608336'
15-
down_revision = 'd98dd8ec85a3'
13+
revision = "1a31ce608336"
14+
down_revision = "d98dd8ec85a3"
1615
branch_labels: str | None = None
1716
depends_on: str | None = None
1817

1918

2019
def upgrade() -> None:
2120
# ### commands auto generated by Alembic - please adjust! ###
22-
op.alter_column('item', 'owner_id',
23-
existing_type=sa.UUID(),
24-
nullable=False)
25-
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
26-
op.create_foreign_key(None, 'item', 'user', ['owner_id'], ['id'], ondelete='CASCADE')
21+
op.alter_column("item", "owner_id", existing_type=sa.UUID(), nullable=False)
22+
op.drop_constraint("item_owner_id_fkey", "item", type_="foreignkey")
23+
op.create_foreign_key(
24+
None, "item", "user", ["owner_id"], ["id"], ondelete="CASCADE",
25+
)
2726
# ### end Alembic commands ###
2827

2928

3029
def downgrade() -> None:
3130
# ### commands auto generated by Alembic - please adjust! ###
32-
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
33-
op.create_foreign_key('item_owner_id_fkey', 'item', 'user', ['owner_id'], ['id'])
34-
op.alter_column('item', 'owner_id',
35-
existing_type=sa.UUID(),
36-
nullable=True)
31+
op.drop_constraint("item_owner_id_fkey", "item", type_="foreignkey")
32+
op.create_foreign_key("item_owner_id_fkey", "item", "user", ["owner_id"], ["id"])
33+
op.alter_column("item", "owner_id", existing_type=sa.UUID(), nullable=True)
3734
# ### end Alembic commands ###

backend/app/alembic/versions/9c0a54914c78_add_max_length_for_string_varchar_.py

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,88 @@
55
Create Date: 2024-06-17 14:42:44.639457
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
10-
import sqlmodel.sql.sqltypes
118

9+
import sqlalchemy as sa
10+
from alembic import op
1211

1312
# revision identifiers, used by Alembic.
14-
revision = '9c0a54914c78'
15-
down_revision = 'e2412789c190'
13+
revision = "9c0a54914c78"
14+
down_revision = "e2412789c190"
1615
branch_labels: str | None = None
1716
depends_on: str | None = None
1817

1918

2019
def upgrade() -> None:
2120
# Adjust the length of the email field in the User table
22-
op.alter_column('user', 'email',
23-
existing_type=sa.String(),
24-
type_=sa.String(length=255),
25-
existing_nullable=False)
21+
op.alter_column(
22+
"user",
23+
"email",
24+
existing_type=sa.String(),
25+
type_=sa.String(length=255),
26+
existing_nullable=False,
27+
)
2628

2729
# Adjust the length of the full_name field in the User table
28-
op.alter_column('user', 'full_name',
29-
existing_type=sa.String(),
30-
type_=sa.String(length=255),
31-
existing_nullable=True)
30+
op.alter_column(
31+
"user",
32+
"full_name",
33+
existing_type=sa.String(),
34+
type_=sa.String(length=255),
35+
existing_nullable=True,
36+
)
3237

3338
# Adjust the length of the title field in the Item table
34-
op.alter_column('item', 'title',
35-
existing_type=sa.String(),
36-
type_=sa.String(length=255),
37-
existing_nullable=False)
39+
op.alter_column(
40+
"item",
41+
"title",
42+
existing_type=sa.String(),
43+
type_=sa.String(length=255),
44+
existing_nullable=False,
45+
)
3846

3947
# Adjust the length of the description field in the Item table
40-
op.alter_column('item', 'description',
41-
existing_type=sa.String(),
42-
type_=sa.String(length=255),
43-
existing_nullable=True)
48+
op.alter_column(
49+
"item",
50+
"description",
51+
existing_type=sa.String(),
52+
type_=sa.String(length=255),
53+
existing_nullable=True,
54+
)
4455

4556

4657
def downgrade() -> None:
4758
# Revert the length of the email field in the User table
48-
op.alter_column('user', 'email',
49-
existing_type=sa.String(length=255),
50-
type_=sa.String(),
51-
existing_nullable=False)
59+
op.alter_column(
60+
"user",
61+
"email",
62+
existing_type=sa.String(length=255),
63+
type_=sa.String(),
64+
existing_nullable=False,
65+
)
5266

5367
# Revert the length of the full_name field in the User table
54-
op.alter_column('user', 'full_name',
55-
existing_type=sa.String(length=255),
56-
type_=sa.String(),
57-
existing_nullable=True)
68+
op.alter_column(
69+
"user",
70+
"full_name",
71+
existing_type=sa.String(length=255),
72+
type_=sa.String(),
73+
existing_nullable=True,
74+
)
5875

5976
# Revert the length of the title field in the Item table
60-
op.alter_column('item', 'title',
61-
existing_type=sa.String(length=255),
62-
type_=sa.String(),
63-
existing_nullable=False)
77+
op.alter_column(
78+
"item",
79+
"title",
80+
existing_type=sa.String(length=255),
81+
type_=sa.String(),
82+
existing_nullable=False,
83+
)
6484

6585
# Revert the length of the description field in the Item table
66-
op.alter_column('item', 'description',
67-
existing_type=sa.String(length=255),
68-
type_=sa.String(),
69-
existing_nullable=True)
86+
op.alter_column(
87+
"item",
88+
"description",
89+
existing_type=sa.String(length=255),
90+
type_=sa.String(),
91+
existing_nullable=True,
92+
)

0 commit comments

Comments
 (0)