Skip to content

Commit 24f2eb0

Browse files
ognis1205mikeas1
andauthored
feat: add A2ABaseModel (#292)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests and linter pass (Run `nox -s format` from the repository root to format) - [x] Appropriate docs were updated (if necessary) Fixes #291 🦕 --------- Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com> Co-authored-by: Mike Smith <mikeas@google.com>
1 parent 07e9b84 commit 24f2eb0

File tree

3 files changed

+116
-82
lines changed

3 files changed

+116
-82
lines changed

scripts/generate_types.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ uv run datamodel-codegen \
3232
--use-one-literal-as-default \
3333
--class-name A2A \
3434
--use-standard-collections \
35-
--use-subclass-enum
35+
--use-subclass-enum \
36+
--base-class a2a._base.A2ABaseModel
3637

3738
echo "Codegen finished successfully."

src/a2a/_base.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pydantic import BaseModel, ConfigDict
2+
3+
4+
class A2ABaseModel(BaseModel):
5+
"""Base class for shared behavior across A2A data models.
6+
7+
Provides a common configuration (e.g., alias-based population) and
8+
serves as the foundation for future extensions or shared utilities.
9+
"""
10+
11+
model_config = ConfigDict(
12+
# SEE: https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.populate_by_name
13+
validate_by_name=True,
14+
validate_by_alias=True,
15+
)

0 commit comments

Comments
 (0)