ci: add fastapi linter

This commit is contained in:
Stéphane Bidoul 2024-11-23 18:04:51 +01:00
parent 90a2994dbe
commit 3fdaec3b47
2 changed files with 4 additions and 2 deletions

View file

@ -58,6 +58,7 @@ select = [
"T20", # flake8-print "T20", # flake8-print
"PLE", # pylint errors "PLE", # pylint errors
"RUF", "RUF",
"FAST", # fastapi
] ]
[tool.ruff.lint.mccabe] [tool.ruff.lint.mccabe]

View file

@ -1,5 +1,6 @@
import hmac import hmac
import logging import logging
from typing import Annotated
from fastapi import APIRouter, BackgroundTasks, Header, Request from fastapi import APIRouter, BackgroundTasks, Header, Request
@ -31,8 +32,8 @@ def _verify_github_signature(
async def receive_payload( async def receive_payload(
background_tasks: BackgroundTasks, background_tasks: BackgroundTasks,
request: Request, request: Request,
x_github_event: str = Header(...), x_github_event: Annotated[str, Header(...)],
x_hub_signature_256: str | None = Header(None), x_hub_signature_256: Annotated[str | None, Header(None)],
) -> None: ) -> None:
body = await request.body() body = await request.body()
if not _verify_github_signature( if not _verify_github_signature(