Skip to content

Commit 130cdfa

Browse files
committed
feat: support new model_validate_json() kwargs
Pydantic added by_alias and by_name keyword arguments to BaseModel.model_validate_json in 2.11.1: pydantic/pydantic@acb0f10 This caused mypy to report that that the Pydantic v2 CloudEvent did not override model_validate_json() correctly. Our override now accepts these newly-added arguments. They have no effect, as the implementation does not use Pydantic to validate the JSON, but we also don't use field aliases, so the only effect they could have in the superclass would be to raise an error if they're both False. Signed-off-by: Hal Blackburn <hwtb2@cam.ac.uk>
1 parent dccd3cf commit 130cdfa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cloudevents/pydantic/v2/event.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ def model_validate_json(
175175
*,
176176
strict: typing.Optional[bool] = None,
177177
context: typing.Optional[typing.Dict[str, Any]] = None,
178+
by_alias: typing.Optional[bool] = None,
179+
by_name: typing.Optional[bool] = None,
178180
) -> "CloudEvent":
179181
return conversion.from_json(cls, json_data)
180182

0 commit comments

Comments
 (0)