style: 统一 Ruff 代码格式

This commit is contained in:
yml2213
2026-08-30 21:04:52 +08:00
parent c891ac982e
commit 47e19ed7b2
90 changed files with 5574 additions and 2350 deletions
@@ -27,7 +27,9 @@ def _indexes(bind, table_name: str) -> set[str]:
return {index["name"] for index in sa.inspect(bind).get_indexes(table_name)}
def _create_index_if_missing(bind, name: str, table_name: str, columns: list[str], unique: bool = False) -> None:
def _create_index_if_missing(
bind, name: str, table_name: str, columns: list[str], unique: bool = False
) -> None:
if name not in _indexes(bind, table_name):
op.create_index(name, table_name, columns, unique=unique)
@@ -59,7 +61,9 @@ def upgrade() -> None:
)
_create_index_if_missing(bind, "ix_huya_accounts_uid", "huya_accounts", ["uid"])
_create_index_if_missing(bind, "ix_huya_accounts_yyuid", "huya_accounts", ["yyuid"])
_create_index_if_missing(bind, "ix_huya_accounts_assigned_to", "huya_accounts", ["assigned_to"])
_create_index_if_missing(
bind, "ix_huya_accounts_assigned_to", "huya_accounts", ["assigned_to"]
)
if not _has_table(bind, "huya_tasks"):
op.create_table(
@@ -79,7 +83,9 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint("id"),
)
_create_index_if_missing(bind, "ix_huya_tasks_batch_id", "huya_tasks", ["batch_id"])
_create_index_if_missing(bind, "ix_huya_tasks_task_type", "huya_tasks", ["task_type"])
_create_index_if_missing(
bind, "ix_huya_tasks_task_type", "huya_tasks", ["task_type"]
)
if not _has_table(bind, "huya_config"):
op.create_table(
@@ -106,13 +112,17 @@ def upgrade() -> None:
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
_create_index_if_missing(bind, "ix_huya_goods_snapshot_product_id", "huya_goods_snapshot", ["product_id"])
_create_index_if_missing(
bind, "ix_huya_goods_snapshot_product_id", "huya_goods_snapshot", ["product_id"]
)
def downgrade() -> None:
bind = op.get_bind()
if _has_table(bind, "huya_goods_snapshot"):
op.drop_index("ix_huya_goods_snapshot_product_id", table_name="huya_goods_snapshot")
op.drop_index(
"ix_huya_goods_snapshot_product_id", table_name="huya_goods_snapshot"
)
op.drop_table("huya_goods_snapshot")
if _has_table(bind, "huya_config"):
op.drop_table("huya_config")