Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use reduce from functools

Marcin Gębalaca53db20c50f
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py
index 0b0b3d8f94..626cbee8ab 100644
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@ -1,3 +1,4 @@
+import functools
import graphene
import operator
@@ -132,11 +133,11 @@ class CategoryType(DjangoObjectType):
if queries:
# Combine filters of the same attribute with OR operator
# and then combine full query with AND operator.
- combine_and = [reduce(operator.or_, [
+ combine_and = [functools.reduce(operator.or_, [
Q(**{'variants__attributes__%s' % key: v}) |
Q(**{'attributes__%s' % key: v})
for v in values]) for key, values in queries.items()]
- query = reduce(operator.and_, combine_and)
+ query = functools.reduce(operator.and_, combine_and)
qs = qs.filter(query).distinct()
if order_by: