From b594dee27894d7d39616ac4c3b0bf06713dc6f21 Mon Sep 17 00:00:00 2001 From: grillazz Date: Sat, 8 Mar 2025 18:34:41 +0100 Subject: [PATCH] fix lint error --- app/api/shakespeare.py | 2 -- app/main.py | 9 ++------- tests/conftest.py | 6 ++++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/api/shakespeare.py b/app/api/shakespeare.py index b6da057..1463e52 100644 --- a/app/api/shakespeare.py +++ b/app/api/shakespeare.py @@ -1,7 +1,6 @@ from typing import Annotated from fastapi import APIRouter, Depends, Query -from fastapi_cache.decorator import cache from sqlalchemy.ext.asyncio import AsyncSession from app.database import get_db @@ -13,7 +12,6 @@ router = APIRouter(prefix="/v1/shakespeare") @router.get( "/", ) -@cache(namespace="test-2", expire=60) async def find_paragraph( character: Annotated[str, Query(description="Character name")], db_session: AsyncSession = Depends(get_db), diff --git a/app/main.py b/app/main.py index bd28098..be10686 100644 --- a/app/main.py +++ b/app/main.py @@ -5,8 +5,6 @@ from apscheduler import AsyncScheduler from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore from apscheduler.eventbrokers.redis import RedisEventBroker from fastapi import Depends, FastAPI -from fastapi_cache import FastAPICache -from fastapi_cache.backends.redis import RedisBackend from app.api.health import router as health_router from app.api.nonsense import router as nonsense_router @@ -15,7 +13,7 @@ from app.api.stuff import router as stuff_router from app.api.user import router as user_router from app.config import settings as global_settings from app.database import engine -from app.redis import get_cache, get_redis +from app.redis import get_redis from app.services.auth import AuthBearer from app.services.scheduler import SchedulerMiddleware from app.utils.logging import AppLogger @@ -31,10 +29,7 @@ async def lifespan(_app: FastAPI): _postgres_dsn = global_settings.postgres_url.unicode_string() try: - # Initialize the cache with the redis connection - redis_cache = await get_cache() - FastAPICache.init(RedisBackend(redis_cache), prefix="fastapi-cache") - # logger.info(FastAPICache.get_cache_status_header()) + # TODO: cache with the redis connection # Initialize the postgres connection pool _app.postgres_pool = await asyncpg.create_pool( dsn=_postgres_dsn, diff --git a/tests/conftest.py b/tests/conftest.py index 2c83229..cee66a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,6 @@ +from collections.abc import AsyncGenerator +from typing import Any + import pytest from httpx import ASGITransport, AsyncClient @@ -28,12 +31,11 @@ async def start_db(): @pytest.fixture(scope="session") -async def client(start_db) -> AsyncClient: +async def client(start_db) -> AsyncGenerator[AsyncClient, Any]: # noqa: ARG001 transport = ASGITransport( app=app, ) async with AsyncClient( - # app=app, base_url="http://testserver/v1", headers={"Content-Type": "application/json"}, transport=transport,