Skip to content

Commit f6acfa9

Browse files
committed
accept plain dicts in create/update methods
1 parent a1921aa commit f6acfa9

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# PyMagento Changelog
22

3+
## 2.11.1 (2025/12/05)
4+
5+
* `get_custom_attribute` and similar functions now accept the new typed dicts `Category` and `Customer` introduced in
6+
the previous release
7+
* `update_category` and `create_category` now accept both a `Category` or a plain dict
8+
* `save_product_media` now accepts both a `MediaGalleryEntry` or a plain dict
9+
310
## 2.11.0 (2025/12/05)
411

512
### Breaking changes

magento/attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
T = TypeVar('T')
99

10-
Item = TypeVar('Item', bound=Union[Product, MagentoEntity])
10+
Item = TypeVar('Item', bound=Union[Category, Customer, Product, MagentoEntity])
1111

1212
# From Magento
1313
CATEGORY_ENTITY_TYPE_ID = 3

magento/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ def get_category_by_name(self, name: str, *, assert_one: bool = False, **kwargs:
299299

300300
return None
301301

302-
def update_category(self, category_id: PathId, category_data: Category, **kwargs: Any) -> Category:
302+
def update_category(self, category_id: PathId, category_data: Union[Category, Dict[str, Any]],
303+
**kwargs: Any) -> Category:
303304
"""Update a category.
304305
305306
:param category_id:
@@ -311,7 +312,7 @@ def update_category(self, category_id: PathId, category_data: Category, **kwargs
311312
**kwargs)
312313
return category
313314

314-
def create_category(self, category: Category, **kwargs: Any) -> Category:
315+
def create_category(self, category: Union[Category, Dict[str, Any]], **kwargs: Any) -> Category:
315316
"""Create a new category and return it."""
316317
category = self.post_json_api("/V1/categories", json={"category": category}, **kwargs)
317318
return category
@@ -939,7 +940,7 @@ def get_product_media(self, sku: Sku, media_id: PathId, **kwargs: Any) -> MediaG
939940
entry: MediaGalleryEntry = self.get_json_api(f"/V1/products/{escape_path(sku)}/media/{media_id}", **kwargs)
940941
return entry
941942

942-
def save_product_media(self, sku: Sku, media_entry: MediaGalleryEntry, **kwargs: Any) -> Any:
943+
def save_product_media(self, sku: Sku, media_entry: Union[MediaGalleryEntry, Dict[str, Any]], **kwargs: Any) -> Any:
943944
"""Save a product media."""
944945
return self.post_json_api(f"/V1/products/{escape_path(sku)}/media", json={"entry": media_entry}, **kwargs)
945946

0 commit comments

Comments
 (0)