Skip to content

Commit c881de8

Browse files
fix(attributes): address review issues in AttributeCollection and inventory deprecation
- Add @validate_call to create() and update() in AttributeCollection - Remove implementation details from update() docstring - Add Notes section to update() listing updatable fields - Fix add_specs() deprecation message: set_values -> add_values Co-authored-by: Prasad <prasad-albert@users.noreply.github.com>
1 parent e37aea0 commit c881de8

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/albert/collections/attributes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def get_by_ids(self, *, ids: list[AttributeId]) -> list[Attribute]:
153153
items = data.get("Items") or data.get("items") or []
154154
return [Attribute(**item) for item in items]
155155

156+
@validate_call
156157
def create(self, *, attribute: Attribute) -> Attribute:
157158
"""Create a new attribute.
158159
@@ -172,12 +173,10 @@ def create(self, *, attribute: Attribute) -> Attribute:
172173
response = self.session.post(self.base_path, json=payload)
173174
return Attribute(**response.json())
174175

176+
@validate_call
175177
def update(self, *, attribute: Attribute) -> Attribute:
176178
"""Update an existing attribute.
177179
178-
Enum value changes are handled transparently via a separate enums
179-
endpoint before applying any field-level patches.
180-
181180
Parameters
182181
----------
183182
attribute : Attribute
@@ -187,6 +186,11 @@ def update(self, *, attribute: Attribute) -> Attribute:
187186
-------
188187
Attribute
189188
The updated Attribute.
189+
190+
Notes
191+
-----
192+
The following fields can be updated: ``reference_name``, ``parameters``,
193+
``validation``, ``unit_id``.
190194
"""
191195
if attribute.id is None:
192196
raise ValueError("Attribute ID is required for update.")

src/albert/collections/inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def get_specs(self, *, ids: list[InventoryId]) -> list[InventorySpecList]:
280280

281281
@deprecated(
282282
"add_specs() is deprecated and will be removed in 2.0. "
283-
"Use client.attributes.set_values() instead."
283+
"Use client.attributes.add_values() instead."
284284
)
285285
@validate_call
286286
def add_specs(

0 commit comments

Comments
 (0)