Skip to content

Commit

Permalink
Fix Ruff errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Delemangi committed Mar 3, 2024
1 parent 47673b6 commit a0037d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backend/app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from app.settings import APISettings

MAX_CONNECTION_ATTEMPTS = 10


@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions backend/app/settings.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a0037d2

Please sign in to comment.