Skip to content

Commit 9361171

Browse files
committed
Bump pydantic-core to v2.40.0
Fix matchers for enhanced serialization warnings due to pydantic/pydantic-core#1799.
1 parent 05b973b commit 9361171

File tree

5 files changed

+125
-118
lines changed

5 files changed

+125
-118
lines changed

pydantic/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"""
2020

2121
# Keep this in sync with the version constraint in the `pyproject.toml` dependencies:
22-
_COMPATIBLE_PYDANTIC_CORE_VERSION = '2.38.0'
22+
_COMPATIBLE_PYDANTIC_CORE_VERSION = '2.40.0'
2323

2424

2525
def version_short() -> str:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = [
4848
'typing-extensions>=4.14.1',
4949
'annotated-types>=0.6.0',
5050
# Keep this in sync with the version in the `check_pydantic_core_version()` function:
51-
'pydantic-core==2.38.0',
51+
'pydantic-core==2.40.0',
5252
'typing-inspection>=0.4.0',
5353
]
5454
dynamic = ['version', 'readme']

tests/test_computed_fields.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,17 @@ def x_list(self) -> list[int]:
355355
m = Model(x=1)
356356
with pytest.warns(
357357
UserWarning,
358-
match=r"Expected `list\[int\]` - serialized value may not be as expected \[input_value='not a list', input_type=str\]",
358+
match=r"Expected `list\[int\]` - serialized value may not be as expected \[field_name=x_list, input_value='not a list', input_type=str\]",
359359
):
360360
m.model_dump()
361361
with pytest.warns(
362362
UserWarning,
363-
match=r"Expected `list\[int\]` - serialized value may not be as expected \[input_value='not a list', input_type=str\]",
363+
match=r"Expected `list\[int\]` - serialized value may not be as expected \[field_name=x_list, input_value='not a list', input_type=str\]",
364364
):
365365
m.model_dump(mode='json')
366366
with pytest.warns(
367367
UserWarning,
368-
match=r"Expected `list\[int\]` - serialized value may not be as expected \[input_value='not a list', input_type=str\]",
368+
match=r"Expected `list\[int\]` - serialized value may not be as expected \[field_name=x_list, input_value='not a list', input_type=str\]",
369369
):
370370
m.model_dump_json()
371371

@@ -787,7 +787,7 @@ def double_x(self) -> T:
787787

788788
with pytest.warns(
789789
UserWarning,
790-
match=r"Expected `int` - serialized value may not be as expected \[input_value='abc', input_type=str\]",
790+
match=r"Expected `int` - serialized value may not be as expected \[field_name=double_x, input_value='abc', input_type=str\]",
791791
):
792792
B[int]().model_dump()
793793

tests/test_construction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_construct_misuse():
2525
assert m.b == 'foobar'
2626
with pytest.warns(
2727
UserWarning,
28-
match=r"Expected `int` - serialized value may not be as expected \[input_value='foobar', input_type=str\]",
28+
match=r"Expected `int` - serialized value may not be as expected \[field_name=b, input_value='foobar', input_type=str\]",
2929
):
3030
assert m.model_dump() == {'b': 'foobar'}
3131
with pytest.raises(AttributeError, match="'Model' object has no attribute 'a'"):
@@ -289,7 +289,7 @@ def test_copy_update(ModelTwo, copy_method):
289289
m_keys = m.model_dump().keys()
290290
with pytest.warns(
291291
UserWarning,
292-
match=r"Expected `float` - serialized value may not be as expected \[input_value='different', input_type=str\]",
292+
match=r"Expected `float` - serialized value may not be as expected \[field_name=a, input_value='different', input_type=str\]",
293293
):
294294
m2_keys = m2.model_dump().keys()
295295
assert set(m_keys) == set(m2_keys) == {'a', 'b', 'c', 'd'}
@@ -447,7 +447,7 @@ class Model(BaseModel):
447447
assert deprecated_copy(m, exclude={'c'}).model_dump() == {'d': {'a': 'ax', 'b': 'bx'}}
448448
with pytest.warns(
449449
UserWarning,
450-
match=r'Expected `str` - serialized value may not be as expected \[input_value=42, input_type=int\]',
450+
match=r'Expected `str` - serialized value may not be as expected \[field_name=c, input_value=42, input_type=int\]',
451451
):
452452
assert deprecated_copy(m, exclude={'c'}, update={'c': 42}).model_dump() == {
453453
'c': 42,

0 commit comments

Comments
 (0)