File tree Expand file tree Collapse file tree 4 files changed +190
-167
lines changed
Expand file tree Collapse file tree 4 files changed +190
-167
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ [0.6.11] - 2026-04-13
5+ ---------------------
6+
7+ Added
8+ ^^^^^
9+ - Compatibility with Pydantic 2.13.
10+
411[0.6.11] - 2026-04-10
512---------------------
613
Original file line number Diff line number Diff line change 1+ import copyreg
12from datetime import datetime
23from typing import TYPE_CHECKING
34from typing import Annotated
@@ -409,14 +410,10 @@ def _dedicated_attributes(
409410 """Return attributes that are not members the parent 'excluded_models'."""
410411
411412 def compare_field_infos (fi1 : Any , fi2 : Any ) -> bool :
412- return (
413- fi1
414- and fi2
415- and fi1 .__slotnames__ == fi2 .__slotnames__
416- and all (
417- getattr (fi1 , attr ) == getattr (fi2 , attr ) for attr in fi1 .__slotnames__
418- )
419- )
413+ if not fi1 or not fi2 :
414+ return False
415+ slot_names = copyreg ._slotnames (type (fi1 )) # type: ignore[attr-defined]
416+ return all (getattr (fi1 , attr ) == getattr (fi2 , attr ) for attr in slot_names )
420417
421418 parent_field_infos = {
422419 field_name : field_info
Original file line number Diff line number Diff line change 1+ import copyreg
12import operator
23
34import pytest
5+ from pydantic .fields import FieldInfo
46
57from scim2_models import URN
68from scim2_models .context import Context
@@ -155,6 +157,25 @@ class Bar(Foo):
155157 }
156158
157159
160+ def test_to_schema_without_slotnames_cache ():
161+ """Regression test for ``FieldInfo.__slotnames__`` usage.
162+
163+ ``FieldInfo.__slotnames__`` is a cache populated lazily by ``copy.copy`` /
164+ ``copyreg._slotnames``. Computing a schema must not rely on that cache
165+ being already warm, otherwise ``to_schema`` raises ``AttributeError`` on a
166+ fresh process.
167+ """
168+ copyreg ._slotnames (FieldInfo )
169+ del FieldInfo .__slotnames__
170+
171+ class Foo (Resource ):
172+ __schema__ = URN ("urn:ietf:params:scim:schemas:core:2.0:Foo" )
173+
174+ foo : str | None = None
175+
176+ Foo .to_schema ()
177+
178+
158179def test_make_python_model_validates_name ():
159180 """Test that make_python_model raises an exception when obj.name is not defined."""
160181 # Test with Schema object without name
You can’t perform that action at this time.
0 commit comments