From 646fc5e1d7abcf43a1c21da1d5e66d1e42701c19 Mon Sep 17 00:00:00 2001 From: fureunoir Date: Sat, 27 Dec 2025 01:08:56 +0300 Subject: [PATCH] Refactor attribute handling in vendor module: update type annotations and simplify `get_or_create` logic. --- engine/core/vendors/__init__.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/engine/core/vendors/__init__.py b/engine/core/vendors/__init__.py index e71dbaa1..ebe72bc5 100644 --- a/engine/core/vendors/__init__.py +++ b/engine/core/vendors/__init__.py @@ -397,7 +397,7 @@ class AbstractVendor: f"No matching vendor found with name {self.vendor_name!r}..." ) from dne - def get_products(self) -> None: + def get_products(self) -> Any: pass def get_products_queryset(self) -> QuerySet[Product]: @@ -523,13 +523,11 @@ class AbstractVendor: value, attr_value_type = self.auto_convert_value(value) - is_created = False - if len(key) > 255: key = key[:255] try: - attribute, is_created = Attribute.objects.get_or_create( + attribute, _ = Attribute.objects.get_or_create( name=key, group=attr_group, value_type=attr_value_type, @@ -565,9 +563,6 @@ class AbstractVendor: ) return None - if not is_created: - return None - av, _ = AttributeValue.objects.get_or_create( attribute=attribute, value=value,