-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
python(pydantic): Use validate_by_name config; populate_by_name will be deprecated #22931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,8 @@ def status_validate_enum(cls, value): | |
| return value | ||
|
|
||
| model_config = ConfigDict( | ||
| populate_by_name=True, | ||
| validate_by_name=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: New Prompt for AI agents |
||
| validate_by_alias=True, | ||
| validate_assignment=True, | ||
| protected_namespaces=(), | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| urllib3 >= 2.1.0, < 3.0.0 | ||
| python_dateutil >= 2.8.2 | ||
| pydantic >= 2 | ||
| pydantic >= 2.11 | ||
| typing-extensions >= 4.7.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,8 @@ class Category(BaseModel): | |
| __properties: ClassVar[List[str]] = ["id", "name"] | ||
|
|
||
| model_config = ConfigDict( | ||
| populate_by_name=True, | ||
| validate_by_name=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: validate_by_name/validate_by_alias require Pydantic >=2.11, but the sample’s pyproject allows >=2 and poetry.lock pins 2.9.2. Poetry installs can use an older Pydantic that doesn’t support these config keys, breaking alias validation. Update the dependency constraints/lock to >=2.11. Prompt for AI agents |
||
| validate_by_alias=True, | ||
| validate_assignment=True, | ||
| protected_namespaces=(), | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| urllib3 >= 2.1.0, < 3.0.0 | ||
| python_dateutil >= 2.8.2 | ||
| pydantic >= 2 | ||
| pydantic >= 2.11 | ||
| typing-extensions >= 4.7.1 |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Dependency version mismatch: requirements.mustache now enforces pydantic >=2.11, but pyproject.mustache (non-poetry1 dependencies) still allows pydantic >=2. This can generate projects that install pydantic <2.11, inconsistent with the new validate_by_name requirement.
Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timonrieger can you please take a look at this feedback, which seems valid to me?