Fix linting

This commit is contained in:
2025-06-06 07:32:40 +02:00
parent ee1e7a16ec
commit a7a09f7784
4 changed files with 11 additions and 6 deletions

View File

@ -4,7 +4,7 @@
import logging
from typing import Any
from fastapi import APIRouter, Depends, Request
from fastapi import APIRouter, Depends
from pydantic import BaseModel, Field, TypeAdapter
from sqlalchemy import select, func, and_
from sqlalchemy.ext.asyncio import AsyncSession

View File

@ -22,7 +22,7 @@ from sshecret_backend.view_models import (
)
from sshecret_backend import audit
from sshecret_backend.types import AsyncDBSessionDep
from .common import get_client_by_id_or_name
from .common import get_client_by_id_or_name, get_client_by_name
LOG = logging.getLogger(__name__)
@ -146,7 +146,7 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
session: Annotated[AsyncSession, Depends(get_db_session)],
) -> None:
"""Delete a secret."""
client = await get_client_by_id_or_name(session, name)
client = await get_client_by_name(session, name)
if not client:
raise HTTPException(
status_code=404, detail="Cannot find a client with the given name."
@ -217,8 +217,10 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
clients: list[str] = []
client_secrets = await session.scalars(
select(ClientSecret)
.join(ClientSecret.client)
.options(selectinload(ClientSecret.client))
.where(ClientSecret.name == name)
.where(Client.is_active.is_(True))
)
for client_secret in client_secrets.all():
if not client_secret.client:
@ -235,7 +237,10 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
"""Get a list of which clients has a named secret."""
detail_list = ClientSecretDetailList(name=name)
client_secrets = await session.scalars(
select(ClientSecret).where(ClientSecret.name == name)
select(ClientSecret)
.options(selectinload(ClientSecret.client))
.where(ClientSecret.name == name)
.where(ClientSecret.client.is_(Client.is_active))
)
for client_secret in client_secrets.all():
if not client_secret.client:

View File

@ -6,7 +6,7 @@ import sqlite3
from collections.abc import AsyncIterator, Generator, Callable
from contextlib import asynccontextmanager
from typing import Any, Literal
from typing import Literal
from sqlalchemy import create_engine, Engine, event, select
from sqlalchemy.ext.asyncio import AsyncConnection, AsyncSession, async_sessionmaker, create_async_engine, AsyncEngine

View File

@ -2,7 +2,7 @@
from collections.abc import AsyncGenerator, Callable, Generator
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Session