fix: fix woodpecker pipelines
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
@@ -11,7 +11,7 @@ from app.core.exceptions import AppException
|
||||
class ErrorResponse(BaseModel):
|
||||
status_code: int
|
||||
message: str
|
||||
details: dict | None = None
|
||||
details: dict[str, str] | None = None
|
||||
timestamp: str
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ async def app_exception_handler(request: Request, exc: AppException) -> JSONResp
|
||||
content={
|
||||
"status_code": exc.status_code,
|
||||
"message": exc.message,
|
||||
"timestamp": datetime.utcnow().isoformat(),
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -32,12 +32,12 @@ async def http_exception_handler(request: Request, exc: HTTPException) -> JSONRe
|
||||
content={
|
||||
"status_code": exc.status_code,
|
||||
"message": str(exc.detail),
|
||||
"timestamp": datetime.utcnow().isoformat(),
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def register_exception_handlers(app: FastAPI):
|
||||
def register_exception_handlers(app: FastAPI) -> None:
|
||||
app.add_exception_handler(
|
||||
AppException,
|
||||
app_exception_handler, # type: ignore[arg-type]
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncGenerator
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
yield
|
||||
|
||||
|
||||
def app_factory():
|
||||
def app_factory() -> FastAPI:
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
return app
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
uvicorn.run(app_factory, factory=True, host="0.0.0.0", port=8000)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user