From a0037d23bd7478b5e6f2241041a9df7ffa495786 Mon Sep 17 00:00:00 2001 From: Delemangi Date: Mon, 4 Mar 2024 00:37:23 +0100 Subject: [PATCH] Fix Ruff errors --- backend/app/database.py | 6 +++--- backend/app/main.py | 4 +++- backend/app/settings.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/app/database.py b/backend/app/database.py index a7e064a..f08ac36 100644 --- a/backend/app/database.py +++ b/backend/app/database.py @@ -17,7 +17,7 @@ def get_engine() -> AsyncEngine: - global engine + global engine # noqa: PLW0603 if SQLALCHEMY_DATABASE_URL is None: raise ValueError("DATABASE_URL environment variable is not set") @@ -30,8 +30,8 @@ def get_engine() -> AsyncEngine: async_session_maker: None | async_sessionmaker = None -def get_session_maker(): - global async_session_maker +def get_session_maker() -> async_sessionmaker: + global async_session_maker # noqa: PLW0603 if async_session_maker is None: async_session_maker = async_sessionmaker( autocommit=False, autoflush=False, bind=get_engine(), expire_on_commit=False diff --git a/backend/app/main.py b/backend/app/main.py index a05cbd7..f02b46d 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -14,6 +14,8 @@ from app.settings import APISettings +MAX_CONNECTION_ATTEMPTS = 10 + @asynccontextmanager async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]: @@ -25,7 +27,7 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]: except Exception as ex: print(ex) time.sleep(1) - if i == 9: + if i == MAX_CONNECTION_ATTEMPTS - 1: sys.exit() Path.mkdir(Path(FILE_PATH), exist_ok=True) diff --git a/backend/app/settings.py b/backend/app/settings.py index 9abd76c..e085171 100644 --- a/backend/app/settings.py +++ b/backend/app/settings.py @@ -1,6 +1,6 @@ -from pydantic_settings import BaseSettings, SettingsConfigDict +from pydantic_settings import BaseSettings class APISettings(BaseSettings): - host: str = "0.0.0.0" + host: str = "0.0.0.0" # noqa: S104 port: int = 8002