Skip to content

Commit e73b6a1

Browse files
committed
refactor: rename '_schema' in 'attribute_urn'
1 parent 11bd0b3 commit e73b6a1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

scim2_models/attributes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class ComplexAttribute(BaseModel):
1717
"""A complex attribute as defined in :rfc:`RFC7643 §2.3.8 <7643#section-2.3.8>`."""
1818

19-
_schema: Optional[str] = None
19+
attribute_urn: Optional[str] = Field(None, exclude=True)
2020

2121
def get_attribute_urn(self, field_name: str) -> str:
2222
"""Build the full URN of the attribute.
@@ -26,7 +26,7 @@ def get_attribute_urn(self, field_name: str) -> str:
2626
alias = (
2727
self.__class__.model_fields[field_name].serialization_alias or field_name
2828
)
29-
return f"{self._schema}.{alias}"
29+
return f"{self.attribute_urn}.{alias}"
3030

3131

3232
class MultiValuedComplexAttribute(ComplexAttribute):

scim2_models/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ def check_mutability_issues(
364364
cls.check_mutability_issues(original_val, replacement_value)
365365

366366
def set_complex_attribute_urns(self) -> None:
367-
"""Navigate through attributes and sub-attributes of type ComplexAttribute, and mark them with a '_schema' attribute.
367+
"""Navigate through attributes and sub-attributes of type ComplexAttribute, and mark them with a 'attribute_urn' attribute.
368368
369-
'_schema' will later be used by 'get_attribute_urn'.
369+
'attribute_urn' will later be used by 'get_attribute_urn'.
370370
"""
371371
from scim2_models.rfc7643.resource import Resource
372372

@@ -378,7 +378,7 @@ def set_complex_attribute_urns(self) -> None:
378378
continue
379379

380380
main_schema = (
381-
getattr(self, "_schema", None)
381+
getattr(self, "attribute_urn", None)
382382
or self.__class__.model_fields["schemas"].default[0]
383383
)
384384

@@ -388,9 +388,9 @@ def set_complex_attribute_urns(self) -> None:
388388
if attr_value := getattr(self, field_name):
389389
if isinstance(attr_value, list):
390390
for item in attr_value:
391-
item._schema = schema
391+
item.attribute_urn = schema
392392
else:
393-
attr_value._schema = schema
393+
attr_value.attribute_urn = schema
394394

395395
@field_serializer("*", mode="wrap")
396396
def scim_serializer(

0 commit comments

Comments
 (0)