minor: ruff format
Some checks failed
ci / ruff (push) Successful in 4s
ci / ty (push) Successful in 4s
ci / tests (push) Failing after 7s
ci / build (push) Has been cancelled

Tabs -> spaces
This commit is contained in:
Chris Milne 2026-06-22 15:04:11 +01:00
parent b2921b73b8
commit fab228bf8f
56 changed files with 3629 additions and 3630 deletions

View file

@ -1,6 +1,7 @@
"""
Database connection and session utilities
"""
from contextlib import contextmanager
from typing import Annotated, Generator
from sqlalchemy import create_engine, StaticPool, Connection
@ -29,6 +30,7 @@ else:
sm = sessionmaker(autocommit=False, expire_on_commit=False, bind=engine)
@contextmanager
def get_db_connection() -> Generator[Connection, None, None]:
with engine.connect() as connection:
@ -38,12 +40,15 @@ def get_db_connection() -> Generator[Connection, None, None]:
connection.rollback()
raise
def _get_db_connection() -> Generator[Connection, None]:
with get_db_connection() as connection:
yield connection
DbConnection = Annotated[Connection, Depends(_get_db_connection)]
@contextmanager
def get_db_session() -> Generator[Session, None, None]:
session = sm()
@ -60,4 +65,5 @@ def _get_db_session() -> Generator[Session, None]:
with get_db_session() as session:
yield session
DbSession = Annotated[Session, Depends(_get_db_session)]

View file

@ -18,9 +18,7 @@ from src.iam.exceptions import GroupNotFoundException, PermNotFoundException
from src.iam.schemas import GroupIDMixin, PermIDMixin
def get_group_model_query(
db: DbSession, group_id: Annotated[int, Query(gt=0)]
) -> Group:
def get_group_model_query(db: DbSession, group_id: Annotated[int, Query(gt=0)]) -> Group:
group_model = db.get(Group, group_id)
if group_model is None:
raise GroupNotFoundException(group_id)
@ -63,9 +61,7 @@ def get_perm_model_body(
perm_model_body_dependency = Annotated[Permission, Depends(get_perm_model_body)]
def get_perm_model_query(
db: DbSession, perm_id: Annotated[int, Query(gt=0)]
) -> Permission:
def get_perm_model_query(db: DbSession, perm_id: Annotated[int, Query(gt=0)]) -> Permission:
perm_model = db.get(Permission, perm_id)
if perm_model is None:
raise PermNotFoundException(perm_id)

View file

@ -468,9 +468,7 @@ async def remove_group_user(
},
},
)
async def get_permissions(
db: DbSession, org_model: org_model_root_claim_query_dependency
):
async def get_permissions(db: DbSession, org_model: org_model_root_claim_query_dependency):
"""
Returns a full list of permissions.
"""

View file

@ -1,6 +1,7 @@
"""
Application root file: Inits the FastAPI application
"""
import os.path
from contextlib import asynccontextmanager
from typing import AsyncGenerator

View file

@ -97,9 +97,7 @@ router = APIRouter(
},
},
)
async def get_org_by_id(
db: DbSession, org_model: org_model_root_claim_query_dependency
):
async def get_org_by_id(db: DbSession, org_model: org_model_root_claim_query_dependency):
"""
Returns organisation details including key member email addresses
"""

View file

@ -16,9 +16,7 @@ from src.service.models import Service
from src.service.schemas import ServiceIDMixin
async def get_service_model_query(
db: DbSession, service_id: Annotated[int, Query(gt=0)]
):
async def get_service_model_query(db: DbSession, service_id: Annotated[int, Query(gt=0)]):
service_model = db.get(Service, service_id)
if service_model is None:
raise ServiceNotFoundException(service_id=service_id)

View file

@ -76,9 +76,7 @@ router = APIRouter(
},
},
)
async def get_all_services(
db: DbSession, org_model: org_model_root_claim_query_dependency
):
async def get_all_services(db: DbSession, org_model: org_model_root_claim_query_dependency):
"""
Returns the ID and name of all services registered to the hub.
"""

View file

@ -57,6 +57,10 @@ async def send_email(recipient: str, subject: str, body: str):
.text(body)
.send()
)
logging.info("Email sent to {} with subject {} (Status: {})".format(recipient, subject, response.status_code))
logging.info(
"Email sent to {} with subject {} (Status: {})".format(
recipient, subject, response.status_code
)
)
except ValidationError as e:
logging.exception(e)