Skip to content

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

Made type more pythonic

NyanKiyoshi0e15b38e3cfa
diff --git a/saleor/graphql/product/types/attributes.py b/saleor/graphql/product/types/attributes.py
index d4146a3cc9..9b82c42469 100644
--- a/saleor/graphql/product/types/attributes.py
+++ b/saleor/graphql/product/types/attributes.py
@@ -5,7 +5,7 @@ import graphene_django_optimizer as gql_optimizer
from graphene import relay
from ....product import models
-from ....product.utils.attributes import T_ASSIGNMENT_REL
+from ....product.utils.attributes import AttributeAssignmentType
from ...core.connection import CountableDjangoObjectType
from ...core.resolvers import resolve_meta, resolve_private_meta
from ...core.types import MetadataObjectType
@@ -205,7 +205,7 @@ class SelectedAttribute(graphene.ObjectType):
description = "Represents a custom attribute."
@staticmethod
- def resolve_value(root: T_ASSIGNMENT_REL, _info):
+ def resolve_value(root: AttributeAssignmentType, _info):
return root.values.first()
diff --git a/saleor/product/utils/attributes.py b/saleor/product/utils/attributes.py
index c162fb1bdb..9a88153070 100644
--- a/saleor/product/utils/attributes.py
+++ b/saleor/product/utils/attributes.py
@@ -9,7 +9,7 @@ from ..models import (
ProductVariant,
)
-T_ASSIGNMENT_REL = Union[AssignedProductAttribute, AssignedVariantAttribute]
+AttributeAssignmentType = Union[AssignedProductAttribute, AssignedVariantAttribute]
def generate_name_for_variant(variant: ProductVariant) -> str:
@@ -26,7 +26,7 @@ def generate_name_for_variant(variant: ProductVariant) -> str:
def _associate_attribute_to_instance(
instance: Union[Product, ProductVariant], attribute_pk: Attribute
-) -> T_ASSIGNMENT_REL:
+) -> AttributeAssignmentType:
"""Associate a given attribute to an instance."""
if isinstance(instance, Product):
attribute_rel = instance.product_type.attributeproduct.get(
@@ -65,7 +65,7 @@ def associate_attribute_values_to_instance(
instance: Union[Product, ProductVariant],
attribute: Attribute,
*values: AttributeValue,
-) -> T_ASSIGNMENT_REL:
+) -> AttributeAssignmentType:
"""Assign given attribute values to a product or variant.
Note: be award this function invokes the ``set`` method on the instance's