diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml new file mode 100644 index 00000000..1f6afb1f --- /dev/null +++ b/.github/workflows/auto-format.yml @@ -0,0 +1,48 @@ +name: Auto-format with Nox + +on: + pull_request: + branches: + - main + +permissions: + contents: write + +jobs: + format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.A2A_BOT_PAT }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Nox + run: pip install nox + + - name: Run Nox formatting session + run: nox -s format + + - name: Check for changes and commit if any + id: commit_changes + run: | + git config user.name "a2a-bot" + git config user.email "a2a-bot@google.com" + + # Check if there are any changes after running Nox + if [ -n "$(git status --porcelain)" ]; then + echo "::notice file=./.github/workflows/auto-format.yml::Formatting changes detected. Committing..." + git add . + git commit -m "chore(format): Auto-format code with Nox" + git push origin HEAD:${{ github.event.pull_request.head.ref }} + echo "changes_committed=true" >> "$GITHUB_OUTPUT" + else + echo "No formatting changes detected. Repository is clean." + echo "changes_committed=false" >> "$GITHUB_OUTPUT" + fi diff --git a/noxfile.py b/noxfile.py index e541b2bb..7d85ea64 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,7 +52,7 @@ def format(session): if format_all: lint_paths_py = ['.'] else: - target_branch = 'origin/main' + target_branch = 'main' unstaged_files = subprocess.run( [ diff --git a/src/a2a/server/request_handlers/request_handler.py b/src/a2a/server/request_handlers/request_handler.py index 811c8da2..a6fe7e20 100644 --- a/src/a2a/server/request_handlers/request_handler.py +++ b/src/a2a/server/request_handlers/request_handler.py @@ -22,6 +22,7 @@ class RequestHandler(ABC): provide to handle incoming JSON-RPC requests. """ + @abstractmethod async def on_get_task( self,