mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-05 15:13:51 -09:00
pydantic pins an exact version of pydantic-core in it's pyproject.toml [1]. This was missed during the last pydantic bump where pydantic-core was erroneously updated to the latest release instead, in commit [2] and [3]. Modify the pydantic runtime test to catch this error in the future. [1] https://github.com/pydantic/pydantic/blob/v2.11.4/pyproject.toml#L49 [2]e1c939e426[3]e42de820cdSigned-off-by: Marcus Hoffmann <buildroot@bubu1.eu> [Julien: add reference to commits introducing the issue] Signed-off-by: Julien Olivain <ju.o@free.fr>
38 lines
828 B
Python
38 lines
828 B
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, PositiveInt
|
|
from pydantic.version import check_pydantic_core_version
|
|
|
|
# pydantic pins an exact version of pydantic core
|
|
# verify these are in sync in buildroots packaging
|
|
assert check_pydantic_core_version()
|
|
|
|
|
|
class User(BaseModel):
|
|
id: int
|
|
name: str = "John Doe"
|
|
signup_ts: datetime | None
|
|
tastes: dict[str, PositiveInt]
|
|
|
|
|
|
external_data = {
|
|
"id": 123,
|
|
"signup_ts": "2019-06-01 12:22",
|
|
"tastes": {
|
|
"wine": 9,
|
|
b"cheese": 7,
|
|
"cabbage": "1",
|
|
},
|
|
}
|
|
|
|
user = User(**external_data)
|
|
expected_user_dump = {
|
|
"id": 123,
|
|
"name": "John Doe",
|
|
"signup_ts": datetime(2019, 6, 1, 12, 22),
|
|
"tastes": {"wine": 9, "cheese": 7, "cabbage": 1},
|
|
}
|
|
|
|
assert user.id == 123
|
|
assert user.model_dump() == expected_user_dump
|