Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

[0.6.11] - 2026-04-13
---------------------

Added
^^^^^
- Compatibility with Pydantic 2.13.

[0.6.11] - 2026-04-10
---------------------

Expand Down
13 changes: 5 additions & 8 deletions scim2_models/resources/resource.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copyreg
from datetime import datetime
from typing import TYPE_CHECKING
from typing import Annotated
Expand Down Expand Up @@ -409,14 +410,10 @@ def _dedicated_attributes(
"""Return attributes that are not members the parent 'excluded_models'."""

def compare_field_infos(fi1: Any, fi2: Any) -> bool:
return (
fi1
and fi2
and fi1.__slotnames__ == fi2.__slotnames__
and all(
getattr(fi1, attr) == getattr(fi2, attr) for attr in fi1.__slotnames__
)
)
if not fi1 or not fi2:
return False
slot_names = copyreg._slotnames(type(fi1)) # type: ignore[attr-defined]
return all(getattr(fi1, attr) == getattr(fi2, attr) for attr in slot_names)

parent_field_infos = {
field_name: field_info
Expand Down
21 changes: 21 additions & 0 deletions tests/test_dynamic_schemas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import copyreg
import operator

import pytest
from pydantic.fields import FieldInfo

from scim2_models import URN
from scim2_models.context import Context
Expand Down Expand Up @@ -155,6 +157,25 @@ class Bar(Foo):
}


def test_to_schema_without_slotnames_cache():
"""Regression test for ``FieldInfo.__slotnames__`` usage.

``FieldInfo.__slotnames__`` is a cache populated lazily by ``copy.copy`` /
``copyreg._slotnames``. Computing a schema must not rely on that cache
being already warm, otherwise ``to_schema`` raises ``AttributeError`` on a
fresh process.
"""
copyreg._slotnames(FieldInfo)
del FieldInfo.__slotnames__

class Foo(Resource):
__schema__ = URN("urn:ietf:params:scim:schemas:core:2.0:Foo")

foo: str | None = None

Foo.to_schema()


def test_make_python_model_validates_name():
"""Test that make_python_model raises an exception when obj.name is not defined."""
# Test with Schema object without name
Expand Down
Loading
Loading