Skip to content

Commit 0c067a0

Browse files
committed
Update type generation to add snake_case alias
1 parent 3800c83 commit 0c067a0

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

.github/actions/spelling/allow.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ AServer
99
AServers
1010
AService
1111
AStarlette
12+
AUser
1213
EUR
1314
GBP
15+
GVsb
1416
INR
1517
JPY
1618
JSONRPCt
@@ -29,6 +31,7 @@ coro
2931
datamodel
3032
dunders
3133
euo
34+
excinfo
3235
genai
3336
getkwargs
3437
gle
@@ -39,9 +42,11 @@ lifecycles
3942
linting
4043
lstrips
4144
mockurl
45+
notif
4246
oauthoidc
4347
oidc
4448
opensource
49+
otherurl
4550
protoc
4651
pyi
4752
pyversions

.github/actions/spelling/expect.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/update-a2a-types.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ on:
44
repository_dispatch:
55
types: [a2a_json_update]
66
workflow_dispatch:
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- "scripts/generate_types.sh"
12+
- "src/a2a/pydantic_base.py"
13+
types:
14+
- opened
15+
- synchronize
16+
- reopened
717

818
jobs:
919
generate_and_pr:
@@ -15,6 +25,9 @@ jobs:
1525
steps:
1626
- name: Checkout code
1727
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event.pull_request.head.ref }}
30+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1831

1932
- name: Set up Python
2033
uses: actions/setup-python@v5
@@ -53,7 +66,19 @@ jobs:
5366
uv run scripts/grpc_gen_post_processor.py
5467
echo "Buf generate finished."
5568
56-
- name: Create Pull Request with Updates
69+
- name: Commit changes to current PR
70+
if: github.event_name == 'pull_request' # Only run this step for pull_request events
71+
run: |
72+
git config user.name "a2a-bot"
73+
git config user.email "[email protected]"
74+
git add ${{ steps.vars.outputs.GENERATED_FILE }} src/a2a/grpc/
75+
git diff --cached --exit-code || git commit -m "feat: Update A2A types from specification 🤖"
76+
git push
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.A2A_BOT_PAT }}
79+
80+
- name: Create Pull Request with Updates (for repository_dispatch/workflow_dispatch)
81+
if: github.event_name != 'pull_request'
5782
uses: peter-evans/create-pull-request@v6
5883
with:
5984
token: ${{ secrets.A2A_BOT_PAT }}

scripts/generate_types.sh

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ uv run datamodel-codegen \
2323
--output "$GENERATED_FILE" \
2424
--target-python-version 3.10 \
2525
--output-model-type pydantic_v2.BaseModel \
26+
--base-class a2a.pydantic_base.A2ABaseModel \
2627
--disable-timestamp \
2728
--use-schema-description \
2829
--use-union-operator \

src/a2a/pydantic_base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""A2A Pydantic Base Model with shared configuration."""
2+
3+
from pydantic import BaseModel, ConfigDict
4+
from pydantic.alias_generators import to_snake
5+
6+
7+
class A2ABaseModel(BaseModel):
8+
"""Base model for all A2A types with shared configuration."""
9+
10+
model_config = ConfigDict(
11+
alias_generator=to_snake,
12+
populate_by_name=True,
13+
arbitrary_types_allowed=True,
14+
)

0 commit comments

Comments
 (0)