Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move color pattern to a constant
Artur Smęt2fff2bc4f69b
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex 1008df5fbe..4a08bbdc36 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -18,6 +18,8 @@ from ..core.types.money import (from ..utils import get_database_idfrom .filters import ProductFilterSet+COLOR_PATTERN = r'^(#[0-9a-fA-F]{3}|#(?:[0-9a-fA-F]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$' # noqa+class ProductAttribuetValueType(graphene.Enum):COLOR = 'COLOR'@@ -45,8 +47,7 @@ def resolve_attribute_list(attributes):def resolve_attribute_value_type(attribute_value):- color_pattern = '^(#[0-9a-fA-F]{3}|#(?:[0-9a-fA-F]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$' # noqa- color_pattern = re.compile(color_pattern)+ color_pattern = re.compile(COLOR_PATTERN)if color_pattern.match(attribute_value):return ProductAttribuetValueType.COLORif 'gradient(' in attribute_value: