diff --git a/poetry.lock b/poetry.lock index ebb19bf..ac6d75b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,21 +2,22 @@ [[package]] name = "alembic" -version = "1.8.0" +version = "1.13.1" description = "A database migration tool for SQLAlchemy." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "alembic-1.8.0-py3-none-any.whl", hash = "sha256:b5ae4bbfc7d1302ed413989d39474d102e7cfa158f6d5969d2497955ffe85a30"}, - {file = "alembic-1.8.0.tar.gz", hash = "sha256:a2d4d90da70b30e70352cd9455e35873a255a31402a438fe24815758d7a0e5e1"}, + {file = "alembic-1.13.1-py3-none-any.whl", hash = "sha256:2edcc97bed0bd3272611ce3a98d98279e9c209e7186e43e75bbb1b2bdfdbcc43"}, + {file = "alembic-1.13.1.tar.gz", hash = "sha256:4932c8558bf68f2ee92b9bbcb8218671c627064d5b08939437af6d77dc05e595"}, ] [package.dependencies] Mako = "*" SQLAlchemy = ">=1.3.0" +typing-extensions = ">=4" [package.extras] -tz = ["python-dateutil"] +tz = ["backports.zoneinfo"] [[package]] name = "attrs" @@ -546,13 +547,13 @@ pytest = ["pytest (>=7)"] [[package]] name = "flask" -version = "2.3.3" +version = "3.0.0" description = "A simple framework for building complex web applications." optional = false python-versions = ">=3.8" files = [ - {file = "flask-2.3.3-py3-none-any.whl", hash = "sha256:f69fcd559dc907ed196ab9df0e48471709175e696d6e698dd4dbe940f96ce66b"}, - {file = "flask-2.3.3.tar.gz", hash = "sha256:09c347a92aa7ff4a8e7f3206795f30d826654baf38b873d0744cd571ca609efc"}, + {file = "flask-3.0.0-py3-none-any.whl", hash = "sha256:21128f47e4e3b9d597a3e8521a329bf56909b690fcc3fa3e477725aa81367638"}, + {file = "flask-3.0.0.tar.gz", hash = "sha256:cfadcdb638b609361d29ec22360d6070a77d7463dcb3ab08d2c2f2f168845f58"}, ] [package.dependencies] @@ -561,7 +562,7 @@ click = ">=8.1.3" importlib-metadata = {version = ">=3.6.0", markers = "python_version < \"3.10\""} itsdangerous = ">=2.1.2" Jinja2 = ">=3.1.2" -Werkzeug = ">=2.3.7" +Werkzeug = ">=3.0.0" [package.extras] async = ["asgiref (>=3.2)"] @@ -1615,4 +1616,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.9, <4" -content-hash = "9bf5837713a183a698b0cc3253b288db0462dd6c2c1609f8612324fd8ee18427" +content-hash = "c04df9b8d21d7f780df9735ff96941988807379ff4f89597fc00bb727f95d7ae" diff --git a/pyproject.toml b/pyproject.toml index 5a45dd3..bb88c25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,8 +30,8 @@ include = [ [tool.poetry.dependencies] python = ">=3.9, <4" -alembic = ">=1.6, <1.8.1" -flask = ">=2.0.2, <3" +alembic = ">=1.6, <2" +flask = ">=3, <4" sqlalchemy = ">=2, <3" [tool.poetry.group.dev.dependencies] diff --git a/valens/migrations/versions/06f82ead211b_merge_duration_and_tempo_in_routine_activity.py b/valens/migrations/versions/06f82ead211b_merge_duration_and_tempo_in_routine_activity.py index 5036b00..8dc8c32 100644 --- a/valens/migrations/versions/06f82ead211b_merge_duration_and_tempo_in_routine_activity.py +++ b/valens/migrations/versions/06f82ead211b_merge_duration_and_tempo_in_routine_activity.py @@ -28,9 +28,7 @@ def upgrade() -> None: - with op.batch_alter_table( - "routine_activity", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("routine_activity", schema=None) as batch_op: for constraint_name, _ in check_constraints_down: batch_op.drop_constraint(constraint_name, type_="check") @@ -42,9 +40,7 @@ def upgrade() -> None: def downgrade() -> None: - with op.batch_alter_table( - "routine_activity", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("routine_activity", schema=None) as batch_op: for constraint_name, _ in check_constraints_up: batch_op.drop_constraint(constraint_name, type_="check") diff --git a/valens/migrations/versions/22f3ddb25741_add_reps_weight_and_rpe_to_routine_activity.py b/valens/migrations/versions/22f3ddb25741_add_reps_weight_and_rpe_to_routine_activity.py index 15dea92..18ab341 100644 --- a/valens/migrations/versions/22f3ddb25741_add_reps_weight_and_rpe_to_routine_activity.py +++ b/valens/migrations/versions/22f3ddb25741_add_reps_weight_and_rpe_to_routine_activity.py @@ -6,6 +6,8 @@ Create Date: 2023-04-01 """ +from typing import Union + import sqlalchemy as sa from alembic import op @@ -15,7 +17,7 @@ depends_on = None -check_constraints = [ +check_constraints: list[tuple[str, Union[str, sa.ColumnElement[bool]]]] = [ ("reps_type_integer", "typeof(reps) = 'integer'"), ("weight_type_real", "typeof(weight) = 'real'"), ("rpe_type_real", "typeof(rpe) = 'real'"), @@ -27,9 +29,7 @@ def upgrade() -> None: - with op.batch_alter_table( - "routine_activity", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("routine_activity", schema=None) as batch_op: batch_op.add_column(sa.Column("reps", sa.Integer(), nullable=False, default=0)) batch_op.add_column(sa.Column("weight", sa.Float(), nullable=False, default=0)) batch_op.add_column(sa.Column("rpe", sa.Float(), nullable=False, default=0)) @@ -38,9 +38,7 @@ def upgrade() -> None: def downgrade() -> None: - with op.batch_alter_table( - "routine_activity", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("routine_activity", schema=None) as batch_op: batch_op.drop_column("rpe") batch_op.drop_column("weight") batch_op.drop_column("reps") diff --git a/valens/migrations/versions/3e7317eb4efa_add_foreign_key_on_delete_cascade.py b/valens/migrations/versions/3e7317eb4efa_add_foreign_key_on_delete_cascade.py index 50eb358..d8a9d58 100644 --- a/valens/migrations/versions/3e7317eb4efa_add_foreign_key_on_delete_cascade.py +++ b/valens/migrations/versions/3e7317eb4efa_add_foreign_key_on_delete_cascade.py @@ -6,6 +6,8 @@ Create Date: 2021-07-18 """ +from typing import Any + from alembic import op from sqlalchemy import CheckConstraint, column @@ -15,22 +17,20 @@ depends_on = None -FOREIGN_KEY_CONSTRAINTS = [ +FOREIGN_KEY_CONSTRAINTS: list[tuple[str, str, str, str, tuple[Any, ...]]] = [ # type: ignore[misc] ( "fk_body_weight_user_id_user", "body_weight", "user", "user_id", - [ - CheckConstraint(column("weight") > 0, name="ck_body_weight_weight_gt_0"), - ], + (CheckConstraint(column("weight") > 0, name="ck_body_weight_weight_gt_0"),), ), ( "fk_body_fat_user_id_user", "body_fat", "user", "user_id", - [ + ( CheckConstraint(column("chest") > 0, name="ck_body_fat_chest_gt_0"), CheckConstraint(column("abdominal") > 0, name="ck_body_fat_abdominal_gt_0"), CheckConstraint(column("tigh") > 0, name="ck_body_fat_tigh_gt_0"), @@ -38,70 +38,70 @@ CheckConstraint(column("subscapular") > 0, name="ck_body_fat_subscapular_gt_0"), CheckConstraint(column("suprailiac") > 0, name="ck_body_fat_suprailiac_gt_0"), CheckConstraint(column("midaxillary") > 0, name="ck_body_fat_midaxillary_gt_0"), - ], + ), ), ( "fk_period_user_id_user", "period", "user", "user_id", - [ + ( CheckConstraint(column("intensity") >= 1, name="ck_period_intensity_ge_1"), CheckConstraint(column("intensity") <= 4, name="ck_period_intensity_le_4"), - ], + ), ), ( "fk_routine_exercise_routine_id_routine", "routine_exercise", "routine", "routine_id", - [ + ( CheckConstraint(column("position") > 0, name="ck_routine_exercise_position_gt_0"), CheckConstraint(column("sets") > 0, name="ck_routine_exercise_sets_gt_0"), - ], + ), ), ( "fk_routine_exercise_exercise_id_exercise", "routine_exercise", "exercise", "exercise_id", - [ + ( CheckConstraint(column("position") > 0, name="ck_routine_exercise_position_gt_0"), CheckConstraint(column("sets") > 0, name="ck_routine_exercise_sets_gt_0"), - ], + ), ), ( "fk_workout_set_workout_id_workout", "workout_set", "workout", "workout_id", - [ + ( CheckConstraint(column("position") > 0, name="ck_workout_set_position_gt_0"), CheckConstraint(column("reps") > 0, name="ck_workout_set_reps_gt_0"), CheckConstraint(column("time") > 0, name="ck_workout_set_time_gt_0"), CheckConstraint(column("weight") > 0, name="ck_workout_set_weight_gt_0"), CheckConstraint(column("rpe") >= 0, name="ck_workout_set_rpe_ge_0"), CheckConstraint(column("rpe") <= 10, name="ck_workout_set_rpe_le_10"), - ], + ), ), ( "fk_workout_set_exercise_id_exercise", "workout_set", "exercise", "exercise_id", - [ + ( CheckConstraint(column("position") > 0, name="ck_workout_set_position_gt_0"), CheckConstraint(column("reps") > 0, name="ck_workout_set_reps_gt_0"), CheckConstraint(column("time") > 0, name="ck_workout_set_time_gt_0"), CheckConstraint(column("weight") > 0, name="ck_workout_set_weight_gt_0"), CheckConstraint(column("rpe") >= 0, name="ck_workout_set_rpe_ge_0"), CheckConstraint(column("rpe") <= 10, name="ck_workout_set_rpe_le_10"), - ], + ), ), - ("fk_exercise_user_id_user", "exercise", "user", "user_id", []), - ("fk_workout_user_id_user", "workout", "user", "user_id", []), - ("fk_workout_routine_id_routine", "workout", "routine", "routine_id", []), - ("fk_routine_user_id_user", "routine", "user", "user_id", []), + ("fk_exercise_user_id_user", "exercise", "user", "user_id", ()), + ("fk_workout_user_id_user", "workout", "user", "user_id", ()), + ("fk_workout_routine_id_routine", "workout", "routine", "routine_id", ()), + ("fk_routine_user_id_user", "routine", "user", "user_id", ()), ] @@ -113,9 +113,7 @@ def upgrade() -> None: local_col, table_args, ) in FOREIGN_KEY_CONSTRAINTS: - with op.batch_alter_table( - source_table, schema=None, table_args=table_args - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table(source_table, schema=None, table_args=table_args) as batch_op: batch_op.drop_constraint(constraint_name, type_="foreignkey") batch_op.create_foreign_key( batch_op.f(constraint_name), referent_table, [local_col], ["id"], ondelete="CASCADE" @@ -130,9 +128,7 @@ def downgrade() -> None: local_col, table_args, ) in FOREIGN_KEY_CONSTRAINTS: - with op.batch_alter_table( - source_table, schema=None, table_args=table_args - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table(source_table, schema=None, table_args=table_args) as batch_op: batch_op.drop_constraint(constraint_name, type_="foreignkey") batch_op.create_foreign_key( batch_op.f(constraint_name), referent_table, [local_col], ["id"] diff --git a/valens/migrations/versions/4b6051594962_add_type_checking.py b/valens/migrations/versions/4b6051594962_add_type_checking.py index fd910d0..32553ce 100644 --- a/valens/migrations/versions/4b6051594962_add_type_checking.py +++ b/valens/migrations/versions/4b6051594962_add_type_checking.py @@ -99,11 +99,11 @@ def upgrade() -> None: for constraint_name, table_name, condition in CHECK_CONSTRAINTS: - with op.batch_alter_table(table_name) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table(table_name) as batch_op: batch_op.create_check_constraint(constraint_name, condition) def downgrade() -> None: for constraint_name, table_name, _ in CHECK_CONSTRAINTS: - with op.batch_alter_table(table_name) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table(table_name) as batch_op: batch_op.drop_constraint(f"ck_{table_name}_{constraint_name}") diff --git a/valens/migrations/versions/4cacd61cb0c5_add_routine_id_to_workout.py b/valens/migrations/versions/4cacd61cb0c5_add_routine_id_to_workout.py index 57186e9..78f7c96 100644 --- a/valens/migrations/versions/4cacd61cb0c5_add_routine_id_to_workout.py +++ b/valens/migrations/versions/4cacd61cb0c5_add_routine_id_to_workout.py @@ -16,7 +16,7 @@ def upgrade() -> None: - with op.batch_alter_table("workout", schema=None) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("workout", schema=None) as batch_op: batch_op.add_column(sa.Column("routine_id", sa.Integer(), nullable=True)) batch_op.create_foreign_key( batch_op.f("fk_workout_routine_id_routine"), "routine", ["routine_id"], ["id"] @@ -24,6 +24,6 @@ def upgrade() -> None: def downgrade() -> None: - with op.batch_alter_table("workout", schema=None) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("workout", schema=None) as batch_op: batch_op.drop_constraint(batch_op.f("fk_workout_routine_id_routine"), type_="foreignkey") batch_op.drop_column("routine_id") diff --git a/valens/migrations/versions/8a0dc258bf2a_extend_workouts.py b/valens/migrations/versions/8a0dc258bf2a_extend_workouts.py index c6ef5b4..486d281 100644 --- a/valens/migrations/versions/8a0dc258bf2a_extend_workouts.py +++ b/valens/migrations/versions/8a0dc258bf2a_extend_workouts.py @@ -6,6 +6,8 @@ Create Date: 2023-02-16 """ +from typing import Union + import sqlalchemy as sa from alembic import op @@ -33,7 +35,7 @@ sa.column("automatic", sa.Boolean), ) -check_constraints = [ +check_constraints: list[tuple[str, Union[str, sa.ColumnElement[bool]]]] = [ ( "target_reps_type_integer_or_null", "typeof(target_reps) = 'integer' or typeof(target_reps) = 'null'", @@ -116,9 +118,7 @@ def upgrade() -> None: sa.PrimaryKeyConstraint("workout_id", "position", name=op.f("pk_workout_rest")), ) - with op.batch_alter_table( - "workout_set", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("workout_set", schema=None) as batch_op: batch_op.add_column(sa.Column("target_reps", sa.Integer(), nullable=True)) batch_op.add_column(sa.Column("target_time", sa.Integer(), nullable=True)) batch_op.add_column(sa.Column("target_weight", sa.Float(), nullable=True)) @@ -136,9 +136,7 @@ def upgrade() -> None: def downgrade() -> None: - with op.batch_alter_table( - "workout_set", schema=None - ) as batch_op: # type: ignore[no-untyped-call] + with op.batch_alter_table("workout_set", schema=None) as batch_op: batch_op.drop_constraint( batch_op.f("fk_workout_set_workout_id_workout_element"), type_="foreignkey" )