chore: update linters (#2095)

* update deps

* ruff auto-fixes

* refactor match statements where possible
This commit is contained in:
Hayden
2023-02-05 09:51:44 -09:00
committed by GitHub
parent d5efaad2c3
commit f3a26f864d
11 changed files with 81 additions and 104 deletions

View File

@@ -43,18 +43,18 @@ class GroupMigrationController(BaseUserController):
"add_migration_tag": add_migration_tag,
}
migrator: BaseMigrator
table: dict[SupportedMigrations, type[BaseMigrator]] = {
SupportedMigrations.chowdown: ChowdownMigrator,
SupportedMigrations.mealie_alpha: MealieAlphaMigrator,
SupportedMigrations.nextcloud: NextcloudMigrator,
SupportedMigrations.paprika: PaprikaMigrator,
}
match migration_type: # noqa match not supported by ruff
case SupportedMigrations.chowdown:
migrator = ChowdownMigrator(**args)
case SupportedMigrations.mealie_alpha:
migrator = MealieAlphaMigrator(**args)
case SupportedMigrations.nextcloud:
migrator = NextcloudMigrator(**args)
case SupportedMigrations.paprika:
migrator = PaprikaMigrator(**args)
case _:
raise ValueError(f"Unsupported migration type: {migration_type}")
constructor = table.get(migration_type, None)
if constructor is None:
raise ValueError(f"Unsupported migration type: {migration_type}")
migrator = constructor(**args)
return migrator.migrate(f"{migration_type.value.title()} Migration")

View File

@@ -1,5 +1,5 @@
from collections.abc import Callable
from functools import cached_property
from typing import Callable
from fastapi import APIRouter, Depends, Query
from pydantic import UUID4