From e98c6198ca6608724127e4248241c4c81c4b55e6 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Wed, 31 Dec 2025 13:56:04 +0530 Subject: [PATCH] Added type check --- .github/workflows/ci.yml | 2 ++ app/main.py | 20 +++++++++++++------- pyproject.toml | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb2184f..0380c72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,5 +42,7 @@ jobs: version: 0.7 - name: Install dependencies run: uv sync + - name: Type check + run: uv run ty check - name: Run tests run: PYTHON_ENV=test uv run pytest diff --git a/app/main.py b/app/main.py index c3eea08..9948c4b 100644 --- a/app/main.py +++ b/app/main.py @@ -1,7 +1,8 @@ import json import logging +from typing import cast -from automa.bot import AsyncAutoma +from automa.bot import AsyncAutoma, CodeProposeParams from automa.bot.webhook import verify_webhook from fastapi import FastAPI, Request, Response @@ -28,7 +29,9 @@ async def automa_hook(request: Request): return Response(status_code=204) # Verify request - if not verify_webhook(env().automa_webhook_secret, signature, payload): + if signature is None or not verify_webhook( + env().automa_webhook_secret, signature, payload + ): logging.warning( "Invalid signature", ) @@ -55,12 +58,15 @@ async def automa_hook(request: Request): # Propose code await automa.code.propose( - { - **body["data"], - "proposal": { - "title": "We changed your code", + cast( + CodeProposeParams, + { + **body["data"], + "proposal": { + "title": "We changed your code", + }, }, - } + ) ) finally: # Clean up diff --git a/pyproject.toml b/pyproject.toml index fdb82d0..51647e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ ] [dependency-groups] -dev = ["httpx~=0.28.1", "pytest>=8.3.5,<9", "ruff~=0.11.2"] +dev = ["httpx~=0.28.1", "pytest>=8.3.5,<9", "ruff~=0.11.2", "ty~=0.0.8"] [tool.pytest.ini_options] pythonpath = "."