Skip to content

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

Fix mypy errors for graphql.order

IKarbowiakafc177589442
diff --git a/saleor/graphql/account/i18n.py b/saleor/graphql/account/i18n.py
index 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: ignore
return instance
diff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.py
index 760e7b4017..2ac4c54eab 100644
--- a/saleor/graphql/menu/types.py
+++ b/saleor/graphql/menu/types.py
@@ -33,7 +33,7 @@ class Menu(CountableDjangoObjectType):
@staticmethod
def resolve_items(root: models.Menu, _info, **_kwargs):
if hasattr(root, "prefetched_items"):
- return root.prefetched_items
+ return root.prefetched_items # type: ignore
return root.items.filter(level=0)
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 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 None
image = 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_order
taxed_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.gross
diff --git a/saleor/graphql/product/utils.py b/saleor/graphql/product/utils.py
index 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: Lis
return
raise 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: Lis
if 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)
)