Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/a2a/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class A2ABaseModel(BaseModel):

model_config = ConfigDict(
# SEE: https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.populate_by_name
validate_by_name=True,
validate_by_alias=True,
serialize_by_alias=True,
populate_by_name=True,
alias_generator=to_camel_custom,
Comment on lines +36 to 37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了提高代码的清晰度和可维护性,建议在此处显式设置 ser_by_alias=True 并为 alias_generator 添加尾随逗号。

  1. 显式 ser_by_alias: 虽然 ser_by_alias=True 是 Pydantic v2 ConfigDict 中的默认设置,但显式声明可以清楚地表明意图,即模型在序列化时应使用别名。考虑到之前的配置中曾尝试设置此行为,显式声明可以避免未来因不了解默认值而产生的困惑。
  2. 尾随逗号: 为 alias_generator 添加尾随逗号是良好的 Python 风格,这使得未来添加新配置项时,git diff 会更清晰,只显示新增的一行。
        populate_by_name=True,
        ser_by_alias=True,
        alias_generator=to_camel_custom,

)
Loading