Updated most python dependencies

Primarily FastAPI and Pydantic to v2. Also ruff to latest.

Updated some code to support Pydantic v2
This commit is contained in:
Donkie
2024-05-23 19:42:27 +02:00
parent 306dbe40af
commit 535fa40ad2
29 changed files with 839 additions and 531 deletions

View File

@@ -120,6 +120,7 @@ class Database:
Returns:
The path to the created backup or None if no backup was created.
"""
if not self.is_file_based_sqlite() or self.connection_url.database is None:
logger.info("Skipping backup as the database is not SQLite.")
@@ -159,6 +160,7 @@ def setup_db(connection_url: URL) -> None:
Args:
connection_url: The URL to connect to the database.
"""
global __db # noqa: PLW0603
__db = Database(connection_url)
@@ -170,6 +172,7 @@ async def backup_global_db(num_backups: int = 5) -> Optional[Path]:
Returns:
The path to the created backup or None if no backup was created.
"""
if __db is None:
raise RuntimeError("DB is not setup.")
@@ -198,6 +201,7 @@ def schedule_tasks(scheduler: Scheduler) -> None:
Args:
scheduler: The scheduler to use for scheduling tasks.
"""
if __db is None:
raise RuntimeError("DB is not setup.")
@@ -218,6 +222,7 @@ async def get_db_session() -> AsyncGenerator[AsyncSession, None]:
Yields:
The database session.
"""
if __db is None or __db.session_maker is None:
raise RuntimeError("DB is not setup.")