From 68db25e02257ebe37e62ab9eacc304dedc7f0a37 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 9 Jul 2025 16:58:31 +0300 Subject: [PATCH] Features: 1) Add initialization for `filter_kwargs` in `delete_inactives` method; Fixes: 1) Streamline queryset filtering in `delete_inactives` by removing redundant line breaks; Extra: 1) Minor formatting cleanup for improved code readability; --- core/vendors/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/vendors/__init__.py b/core/vendors/__init__.py index 6c3c4b8e..519a9915 100644 --- a/core/vendors/__init__.py +++ b/core/vendors/__init__.py @@ -301,6 +301,7 @@ class AbstractVendor: raise ValueError(f"Invalid method {method!r} for products update...") def delete_inactives(self, inactivation_method: str = "deactivate", size: int = 5000): + filter_kwargs: dict[str, Any] = {} # noinspection PyUnreachableCode match inactivation_method: case "deactivate": @@ -311,9 +312,7 @@ class AbstractVendor: raise ValueError(f"Invalid method {inactivation_method!r} for products cleaner...") while True: - batch_ids = list(self.get_products_queryset() - .filter(**filter_kwargs) - .values_list("pk", flat=True)[:size]) + batch_ids = list(self.get_products_queryset().filter(**filter_kwargs).values_list("pk", flat=True)[:size]) if not batch_ids: break with suppress(Exception):