Skip to content

Commit 7a50125

Browse files
committed
fix: pydantic warnings
PydanticDeprecatedSince211: Accessing this attribute on the instance is deprecated, and will be removed in Pydantic V3. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
1 parent 2d4aecc commit 7a50125

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

doc/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
[0.3.2] - Unreleased
5+
--------------------
6+
7+
Fixed
8+
^^^^^
9+
- Pydantic warning.
10+
411
[0.3.1] - 2025-03-07
512
--------------------
613

scim2_models/base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,14 @@ def mark_with_schema(self):
649649
"""
650650
from scim2_models.rfc7643.resource import Resource
651651

652-
for field_name in self.model_fields:
652+
for field_name in self.__class__.model_fields:
653653
attr_type = self.get_field_root_type(field_name)
654654
if not is_complex_attribute(attr_type):
655655
continue
656656

657657
main_schema = (
658658
getattr(self, "_schema", None)
659-
or self.model_fields["schemas"].default[0]
659+
or self.__class__.model_fields["schemas"].default[0]
660660
)
661661

662662
separator = ":" if isinstance(self, Resource) else "."
@@ -847,8 +847,10 @@ def get_attribute_urn(self, field_name: str) -> str:
847847
848848
See :rfc:`RFC7644 §3.10 <7644#section-3.10>`.
849849
"""
850-
main_schema = self.model_fields["schemas"].default[0]
851-
alias = self.model_fields[field_name].serialization_alias or field_name
850+
main_schema = self.__class__.model_fields["schemas"].default[0]
851+
alias = (
852+
self.__class__.model_fields[field_name].serialization_alias or field_name
853+
)
852854

853855
# if alias contains a ':' this is an extension urn
854856
full_urn = alias if ":" in alias else f"{main_schema}:{alias}"
@@ -865,7 +867,9 @@ def get_attribute_urn(self, field_name: str) -> str:
865867
866868
See :rfc:`RFC7644 §3.10 <7644#section-3.10>`.
867869
"""
868-
alias = self.model_fields[field_name].serialization_alias or field_name
870+
alias = (
871+
self.__class__.model_fields[field_name].serialization_alias or field_name
872+
)
869873
return f"{self._schema}.{alias}"
870874

871875

0 commit comments

Comments
 (0)