Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix mypy errors for graphql.order
IKarbowiakafc177589442
diff --git a/saleor/graphql/account/i18n.py b/saleor/graphql/account/i18n.pyindex a7269a6454..d600c3c332 100644--- a/saleor/graphql/account/i18n.py+++ b/saleor/graphql/account/i18n.py@@ -34,6 +34,6 @@ class I18nMixin:if not instance:instance = Address()- cls.construct_instance(instance, address_form.cleaned_data)- cls.clean_instance(instance)+ cls.construct_instance(instance, address_form.cleaned_data) # type: ignore+ cls.clean_instance(instance) # type: ignorereturn instancediff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.pyindex 760e7b4017..2ac4c54eab 100644--- a/saleor/graphql/menu/types.py+++ b/saleor/graphql/menu/types.py@@ -33,7 +33,7 @@ class Menu(CountableDjangoObjectType):@staticmethoddef resolve_items(root: models.Menu, _info, **_kwargs):if hasattr(root, "prefetched_items"):- return root.prefetched_items+ return root.prefetched_items # type: ignorereturn root.items.filter(level=0)diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex c0b1582af1..866fef7bc8 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -244,7 +244,7 @@ class OrderLine(CountableDjangoObjectType):prefetch_related=["variant__images", "variant__product__images"])def resolve_thumbnail(root: models.OrderLine, info, *, size=255):- if not root.variant_id:+ if not root.variant:return Noneimage = root.variant.get_first_image()if image:@@ -483,8 +483,10 @@ class Order(MetadataObjectType, CountableDjangoObjectType):manager = get_extensions_manager()display_gross = display_gross_prices()for shipping_method in available:+ # Ignore typing check because it is checked in+ # get_valid_shipping_methods_for_ordertaxed_price = manager.apply_taxes_to_shipping(- shipping_method.price, root.shipping_address+ shipping_method.price, root.shipping_address # type: ignore)if display_gross:shipping_method.price = taxed_price.grossdiff --git a/saleor/graphql/product/utils.py b/saleor/graphql/product/utils.pyindex b7d80c3f70..2dc23272a9 100644--- a/saleor/graphql/product/utils.py+++ b/saleor/graphql/product/utils.py@@ -14,19 +14,19 @@ def validate_attribute_input_for_product(instance: models.Attribute, values: Lisreturnraise ValidationError(f"{instance.slug} expects a value but none were given",- code=ProductErrorCode.REQUIRED,+ code=str(ProductErrorCode.REQUIRED),)if instance.input_type != AttributeInputType.MULTISELECT and len(values) != 1:raise ValidationError(f"A {instance.input_type} attribute must take only one value",- code=ProductErrorCode.INVALID,+ code=str(ProductErrorCode.INVALID),)for value in values:if not value.strip():raise ValidationError(- "Attribute values cannot be blank", code=ProductErrorCode.REQUIRED+ "Attribute values cannot be blank", code=str(ProductErrorCode.REQUIRED))@@ -34,18 +34,18 @@ def validate_attribute_input_for_variant(instance: models.Attribute, values: Lisif not values:raise ValidationError(f"{instance.slug} expects a value but none were given",- code=ProductErrorCode.REQUIRED,+ code=str(ProductErrorCode.REQUIRED),)if len(values) != 1:raise ValidationError(f"A variant attribute cannot take more than one value",- code=ProductErrorCode.INVALID,+ code=str(ProductErrorCode.INVALID),)if not values[0].strip():raise ValidationError(- "Attribute values cannot be blank", code=ProductErrorCode.REQUIRED+ "Attribute values cannot be blank", code=str(ProductErrorCode.REQUIRED))