Skip to content

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

Fix errors for graphql.checkout and graphql.menu

IKarbowiak6c30ed49d3ce
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index 120baf178a..d7377f9e1d 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -66,14 +66,14 @@ def clean_shipping_method(
if not checkout.is_shipping_required():
raise ValidationError(
- ERROR_DOES_NOT_SHIP, code=CheckoutErrorCode.SHIPPING_NOT_REQUIRED
+ ERROR_DOES_NOT_SHIP, code=str(CheckoutErrorCode.SHIPPING_NOT_REQUIRED)
)
if not checkout.shipping_address:
raise ValidationError(
"Cannot choose a shipping method for a checkout without the "
"shipping address.",
- code=CheckoutErrorCode.SHIPPING_ADDRESS_NOT_SET,
+ code=str(CheckoutErrorCode.SHIPPING_ADDRESS_NOT_SET),
)
valid_methods = get_valid_shipping_methods_for_checkout(checkout, discounts)
@@ -217,7 +217,7 @@ class CheckoutCreate(ModelMutation, I18nMixin):
return None
@classmethod
- def clean_input(cls, info, instance: models.Checkout, data):
+ def clean_input(cls, info, instance: models.Checkout, data): # type: ignore
cleaned_input = super().clean_input(info, instance, data)
user = info.context.user
diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.py
index c5822fbb89..33f0cef89e 100644
--- a/saleor/graphql/menu/mutations.py
+++ b/saleor/graphql/menu/mutations.py
@@ -155,13 +155,13 @@ def _validate_menu_item_instance(
"""Check if the value to assign as a menu item matches the expected model."""
item = cleaned_input.get(field)
if item is not None:
- if not isinstance(item, expected_model):
+ if not isinstance(item, expected_model): # type: ignore
msg = (
f"Enter a valid {expected_model._meta.verbose_name} ID "
f"(got {item._meta.verbose_name} ID)."
)
raise ValidationError(
- {field: ValidationError(msg, code=MenuErrorCode.INVALID_MENU_ITEM)}
+ {field: ValidationError(msg, code=str(MenuErrorCode.INVALID_MENU_ITEM))}
)
@@ -289,7 +289,7 @@ class MenuItemMove(BaseMutation):
{
"parent_id": ValidationError(
"Cannot assign a node to itself.",
- code=MenuErrorCode.CANNOT_ASSIGN_NODE,
+ code=str(MenuErrorCode.CANNOT_ASSIGN_NODE),
)
}
)
@@ -307,7 +307,7 @@ class MenuItemMove(BaseMutation):
"Cannot assign a node as child of "
"one of its descendants."
),
- code=MenuErrorCode.CANNOT_ASSIGN_NODE,
+ code=str(MenuErrorCode.CANNOT_ASSIGN_NODE),
)
}
)
@@ -371,7 +371,7 @@ class MenuItemMove(BaseMutation):
@classmethod
@transaction.atomic
- def perform_mutation(cls, _root, info, menu: str, moves):
+ def perform_mutation(cls, _root, info, menu: str, moves): # type: ignore
qs = models.Menu.objects.prefetch_related("items")
menu = cls.get_node_or_error(info, menu, only_type=Menu, field="menu", qs=qs)