Skip to content

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

Refactor shadow names and unused parameters

NyanKiyoshid29d2eb68ef9
diff --git a/saleor/graphql/account/bulk_mutations.py b/saleor/graphql/account/bulk_mutations.py
index 9dadb42aa1..b9a41831e3 100644
--- a/saleor/graphql/account/bulk_mutations.py
+++ b/saleor/graphql/account/bulk_mutations.py
@@ -22,7 +22,7 @@ class CustomerBulkDelete(CustomerDeleteMixin, UserBulkDelete):
model = models.User
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@@ -32,5 +32,5 @@ class StaffBulkDelete(StaffDeleteMixin, UserBulkDelete):
model = models.User
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_staff')
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index cbfefaaf8a..01904cd55b 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -124,14 +124,14 @@ class CustomerCreate(ModelMutation, I18nMixin):
model = models.User
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@classmethod
- def clean_input(cls, info, instance, input):
- shipping_address_data = input.pop(SHIPPING_ADDRESS_FIELD, None)
- billing_address_data = input.pop(BILLING_ADDRESS_FIELD, None)
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ shipping_address_data = raw_input.pop(SHIPPING_ADDRESS_FIELD, None)
+ billing_address_data = raw_input.pop(BILLING_ADDRESS_FIELD, None)
+ cleaned_input = super().clean_input(info, instance, raw_input)
if shipping_address_data:
shipping_address = cls.validate_address(
@@ -189,7 +189,7 @@ class LoggedUserUpdate(CustomerCreate):
model = models.User
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.is_authenticated
@classmethod
@@ -214,7 +214,7 @@ class CustomerDelete(CustomerDeleteMixin, UserDelete):
required=True, description='ID of a customer to delete.')
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@@ -230,12 +230,12 @@ class StaffCreate(ModelMutation):
model = models.User
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_staff')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
# set is_staff to True to create a staff user
cleaned_input['is_staff'] = True
@@ -279,8 +279,8 @@ class StaffUpdate(StaffCreate):
'is_active': 'Cannot deactivate superuser\'s account.'})
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
is_active = cleaned_input.get('is_active')
if is_active is not None:
cls.clean_is_active(is_active, instance, info.context.user)
@@ -297,7 +297,7 @@ class StaffDelete(StaffDeleteMixin, UserDelete):
required=True, description='ID of a staff user to delete.')
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_staff')
@classmethod
@@ -338,8 +338,8 @@ class SetPassword(ModelMutation):
model = models.User
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
token = cleaned_input.pop('token')
if not default_token_generator.check_token(instance, token):
raise ValidationError({'token': SetPassword.INVALID_TOKEN})
@@ -359,11 +359,11 @@ class PasswordReset(BaseMutation):
description = 'Sends password reset email'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@classmethod
- def perform_mutation(cls, root, info, email):
+ def perform_mutation(cls, _root, info, email):
try:
user = models.User.objects.get(email=email)
except ObjectDoesNotExist:
@@ -390,8 +390,8 @@ class CustomerPasswordReset(BaseMutation):
description = 'Resets the customer\'s password.'
@classmethod
- def perform_mutation(cls, root, info, input):
- email = input['email']
+ def perform_mutation(cls, _root, info, **data):
+ email = data.get('input')['email']
try:
user = models.User.objects.get(email=email)
except ObjectDoesNotExist:
@@ -428,7 +428,7 @@ class AddressCreate(ModelMutation):
return response
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@@ -448,12 +448,12 @@ class AddressUpdate(ModelMutation):
exclude = ['user_addresses']
@classmethod
- def clean_input(cls, info, instance, input):
+ def clean_input(cls, info, instance, raw_input):
# Method user_is_allowed cannot be used for permission check, because
# it doesn't have the address instance.
if not can_edit_address(info.context.user, instance):
raise PermissionDenied()
- return super().clean_input(info, instance, input)
+ return super().clean_input(info, instance, raw_input)
@classmethod
def perform_mutation(cls, root, info, **data):
@@ -531,11 +531,11 @@ class AddressSetDefault(BaseMutation):
description = 'Sets a default address for the given user.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('account.manage_users')
@classmethod
- def perform_mutation(cls, root, info, address_id, user_id, type):
+ def perform_mutation(cls, _root, info, address_id, user_id, **data):
address = cls.get_node_or_error(
info, address_id, field='address_id', only_type=Address)
user = cls.get_node_or_error(
@@ -545,12 +545,14 @@ class AddressSetDefault(BaseMutation):
raise ValidationError({
'address_id': 'The address doesn\'t belong to that user.'})
- if type == AddressTypeEnum.BILLING.value:
+ raw_address_type = data.get('type')
+ if raw_address_type == AddressTypeEnum.BILLING.value:
address_type = AddressType.BILLING
- elif type == AddressTypeEnum.SHIPPING.value:
+ elif raw_address_type == AddressTypeEnum.SHIPPING.value:
address_type = AddressType.SHIPPING
else:
- raise ValueError('Unknown value of AddressTypeEnum: %s' % type)
+ raise ValueError(
+ 'Unknown value of AddressTypeEnum: %s' % raw_address_type)
utils.change_user_default_address(user, address, address_type)
return cls(user=user)
@@ -572,7 +574,7 @@ class CustomerAddressCreate(ModelMutation):
exclude = ['user_addresses']
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.is_authenticated
@classmethod
@@ -606,11 +608,11 @@ class CustomerSetDefaultAddress(BaseMutation):
description = 'Sets a default address for the authenticated user.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.is_authenticated
@classmethod
- def perform_mutation(cls, root, info, id, type):
+ def perform_mutation(cls, _root, info, **data):
address = cls.get_node_or_error(info, id, Address)
user = info.context.user
@@ -618,9 +620,10 @@ class CustomerSetDefaultAddress(BaseMutation):
raise ValidationError({
'id': 'The address doesn\'t belong to that user.'})
- if type == AddressTypeEnum.BILLING.value:
+ raw_address_type = data.get('type')
+ if raw_address_type == AddressTypeEnum.BILLING.value:
address_type = AddressType.BILLING
- elif type == AddressTypeEnum.SHIPPING.value:
+ elif raw_address_type == AddressTypeEnum.SHIPPING.value:
address_type = AddressType.SHIPPING
utils.change_user_default_address(user, address, address_type)
@@ -648,7 +651,7 @@ class UserAvatarUpdate(BaseMutation):
@classmethod
@staff_member_required
- def perform_mutation(cls, root, info, image):
+ def perform_mutation(cls, _root, info, image):
user = info.context.user
image_data = info.context.FILES.get(image)
validate_image_file(image_data, 'image')
@@ -671,7 +674,7 @@ class UserAvatarDelete(BaseMutation):
@classmethod
@staff_member_required
- def perform_mutation(cls, root, info):
+ def perform_mutation(cls, _root, info):
user = info.context.user
user.avatar.delete_sized_images()
user.avatar.delete()
diff --git a/saleor/graphql/account/resolvers.py b/saleor/graphql/account/resolvers.py
index fe882433a3..f61a78958d 100644
--- a/saleor/graphql/account/resolvers.py
+++ b/saleor/graphql/account/resolvers.py
@@ -33,8 +33,8 @@ def resolve_staff_users(info, query):
return gql_optimizer.query(qs, info)
-def resolve_address_validator(info, input):
- country_code = input['country_code']
+def resolve_address_validator(info, data):
+ country_code = data['country_code']
if not country_code:
client_ip = get_client_ip(info.context)
country = get_country_by_ip(client_ip)
@@ -44,8 +44,8 @@ def resolve_address_validator(info, input):
return None
params = {
'country_code': country_code,
- 'country_area': input['country_area'],
- 'city_area': input['city_area']}
+ 'country_area': data['country_area'],
+ 'city_area': data['city_area']}
rules = get_validation_rules(params)
return AddressValidationData(
country_code=rules.country_code,
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index dceb4a5b68..f10c7a9a88 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -106,10 +106,10 @@ class CheckoutCreate(ModelMutation, I18nMixin):
return_field_name = 'checkout'
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
user = info.context.user
- lines = input.pop('lines', None)
+ lines = raw_input.pop('lines', None)
if lines:
variant_ids = [line.get('variant_id') for line in lines]
variants = cls.get_nodes_or_error(
@@ -127,21 +127,23 @@ class CheckoutCreate(ModelMutation, I18nMixin):
default_billing_address = user.default_billing_address
default_shipping_address = user.default_shipping_address
- if 'shipping_address' in input:
- shipping_address = cls.validate_address(input['shipping_address'])
+ if 'shipping_address' in raw_input:
+ shipping_address = cls.validate_address(
+ raw_input['shipping_address'])
cleaned_input['shipping_address'] = shipping_address
else:
cleaned_input['shipping_address'] = default_shipping_address
- if 'billing_address' in input:
- billing_address = cls.validate_address(input['billing_address'])
+ if 'billing_address' in raw_input:
+ billing_address = cls.validate_address(
+ raw_input['billing_address'])
cleaned_input['billing_address'] = billing_address
else:
cleaned_input['billing_address'] = default_billing_address
# Use authenticated user's email as default email
if user.is_authenticated:
- email = input.pop('email', None)
+ email = raw_input.pop('email', None)
cleaned_input['email'] = email or user.email
return cleaned_input
@@ -166,7 +168,7 @@ class CheckoutCreate(ModelMutation, I18nMixin):
add_variant_to_cart(instance, variant, quantity)
@classmethod
- def perform_mutation(cls, root, info, input):
+ def perform_mutation(cls, root, info, **data):
user = info.context.user
# `perform_mutation` is overriden to properly get or create a checkout
@@ -180,7 +182,8 @@ class CheckoutCreate(ModelMutation, I18nMixin):
else:
checkout = models.Cart()
- cleaned_input = cls.clean_input(info, checkout, input)
+ cleaned_input = cls.clean_input(
+ data.get('input'), checkout, input)
checkout = cls.construct_instance(checkout, cleaned_input)
cls.clean_instance(checkout)
cls.save(info, checkout, cleaned_input)
@@ -257,7 +260,7 @@ class CheckoutLineDelete(BaseMutation):
description = 'Deletes a CheckoutLine.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id, line_id):
+ def perform_mutation(cls, _root, info, checkout_id, line_id):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
line = cls.get_node_or_error(
@@ -291,7 +294,7 @@ class CheckoutCustomerAttach(BaseMutation):
description = 'Sets the customer as the owner of the Checkout.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id, customer_id):
+ def perform_mutation(cls, _root, info, checkout_id, customer_id):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
customer = cls.get_node_or_error(
@@ -311,7 +314,7 @@ class CheckoutCustomerDetach(BaseMutation):
description = 'Removes the user assigned as the owner of the checkout.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id):
+ def perform_mutation(cls, _root, info, checkout_id):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
checkout.user = None
@@ -390,7 +393,7 @@ class CheckoutEmailUpdate(BaseMutation):
description = 'Updates email address in the existing Checkout object.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id, email):
+ def perform_mutation(cls, _root, info, checkout_id, email):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
@@ -412,7 +415,7 @@ class CheckoutShippingMethodUpdate(BaseMutation):
description = 'Updates the shipping address of the checkout.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id, shipping_method_id):
+ def perform_mutation(cls, _root, info, checkout_id, shipping_method_id):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
shipping_method = cls.get_node_or_error(
@@ -445,7 +448,7 @@ class CheckoutComplete(BaseMutation):
'payment before it can be performed.')
@classmethod
- def perform_mutation(cls, root, info, checkout_id):
+ def perform_mutation(cls, _root, info, checkout_id):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
@@ -496,7 +499,7 @@ class CheckoutUpdateVoucher(BaseMutation):
'field to remove voucher from checkout.')
@classmethod
- def perform_mutation(cls, root, info, checkout_id, voucher_code=None):
+ def perform_mutation(cls, _root, info, checkout_id, voucher_code=None):
checkout = cls.get_node_or_error(
info, checkout_id, only_type=Checkout, field='checkout_id')
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 6ee012cbd4..46b8e3602e 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -221,7 +221,7 @@ class ModelMutation(BaseMutation):
arguments=arguments, fields=fields)
@classmethod
- def clean_input(cls, info, instance, input):
+ def clean_input(cls, info, instance, raw_input):
"""Clean input data received from mutation arguments.
Fields containing IDs or lists of IDs are automatically resolved into
@@ -253,8 +253,8 @@ class ModelMutation(BaseMutation):
cleaned_input = {}
for field_name, field in InputCls._meta.fields.items():
- if field_name in input:
- value = input[field_name]
+ if field_name in raw_input:
+ value = raw_input[field_name]
# handle list of IDs field
if value is not None and is_list_of_ids(field):
@@ -286,6 +286,17 @@ class ModelMutation(BaseMutation):
if f.name in cleaned_data and cleaned_data[f.name] is not None:
f.save_form_data(instance, cleaned_data[f.name])
+ @classmethod
+ def user_is_allowed(cls, *args):
+ """Determine whether user has rights to perform this mutation.
+
+ Default implementation assumes that user is allowed to perform any
+ mutation. By overriding this method, you can restrict access to it.
+ `user` is the User instance associated with the request and `input` is
+ the input data provided as mutation arguments.
+ """
+ return True
+
@classmethod
def success_response(cls, instance):
"""Return a success response."""
@@ -307,7 +318,7 @@ class ModelMutation(BaseMutation):
return instance
@classmethod
- def perform_mutation(cls, root, info, **data):
+ def perform_mutation(cls, _root, info, **data):
"""Perform model mutation.
Depending on the input data, `mutate` either creates a new instance or
@@ -316,8 +327,8 @@ class ModelMutation(BaseMutation):
created based on the model associated with this mutation.
"""
instance = cls.get_instance(info, **data)
- input_data = data.get('input')
- cleaned_input = cls.clean_input(info, instance, input_data)
+ raw_input = data.get('input')
+ cleaned_input = cls.clean_input(info, instance, raw_input)
instance = cls.construct_instance(instance, cleaned_input)
cls.clean_instance(instance)
cls.save(info, instance, cleaned_input)
diff --git a/saleor/graphql/discount/bulk_mutations.py b/saleor/graphql/discount/bulk_mutations.py
index 35bda54a11..d0796a88b0 100644
--- a/saleor/graphql/discount/bulk_mutations.py
+++ b/saleor/graphql/discount/bulk_mutations.py
@@ -16,7 +16,7 @@ class SaleBulkDelete(ModelBulkDeleteMutation):
model = models.Sale
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@@ -32,5 +32,5 @@ class VoucherBulkDelete(ModelBulkDeleteMutation):
model = models.Voucher
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index 05c5f77a75..283ef78c33 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -105,15 +105,15 @@ class VoucherCreate(ModelMutation):
model = models.Voucher
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@classmethod
- def clean_input(cls, info, instance, input):
- code = input.get('code', None)
+ def clean_input(cls, info, instance, raw_input):
+ code = raw_input.get('code', None)
if code == '':
- input['code'] = generate_voucher_code()
- cleaned_input = super().clean_input(info, instance, input)
+ raw_input['code'] = generate_voucher_code()
+ cleaned_input = super().clean_input(info, instance, raw_input)
return cleaned_input
@@ -139,7 +139,7 @@ class VoucherDelete(ModelDeleteMutation):
model = models.Voucher
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@@ -164,14 +164,14 @@ class VoucherAddCatalogues(VoucherBaseCatalogueMutation):
description = 'Adds products, categories, collections to a voucher.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@classmethod
- def perform_mutation(cls, root, info, id, input):
+ def perform_mutation(cls, _root, info, **data):
voucher = cls.get_node_or_error(
- info, id, only_type=Voucher, field='voucher_id')
- cls.add_catalogues_to_node(voucher, input)
+ info, data.get('id'), only_type=Voucher, field='voucher_id')
+ cls.add_catalogues_to_node(voucher, data.get('input'))
return VoucherAddCatalogues(voucher=voucher)
@@ -181,14 +181,14 @@ class VoucherRemoveCatalogues(VoucherBaseCatalogueMutation):
'Removes products, categories, collections from a voucher.')
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@classmethod
- def perform_mutation(cls, root, info, id, input):
+ def perform_mutation(cls, _root, info, **data):
voucher = cls.get_node_or_error(
- info, id, only_type=Voucher, field='voucher_id')
- cls.remove_catalogues_from_node(voucher, input)
+ info, data.get('id'), only_type=Voucher, field='voucher_id')
+ cls.remove_catalogues_from_node(voucher, data.get('input'))
return VoucherRemoveCatalogues(voucher=voucher)
@@ -224,7 +224,7 @@ class SaleCreate(ModelMutation):
model = models.Sale
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@@ -239,7 +239,7 @@ class SaleUpdate(ModelMutation):
model = models.Sale
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@@ -252,7 +252,7 @@ class SaleDelete(ModelDeleteMutation):
model = models.Sale
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@@ -275,13 +275,14 @@ class SaleAddCatalogues(SaleBaseCatalogueMutation):
description = 'Adds products, categories, collections to a voucher.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- sale = cls.get_node_or_error(info, id, only_type=Sale, field='sale_id')
- cls.add_catalogues_to_node(sale, input)
+ def perform_mutation(cls, _root, info, **data):
+ sale = cls.get_node_or_error(
+ info, data.get('id'), only_type=Sale, field='sale_id')
+ cls.add_catalogues_to_node(sale, data.get('input'))
return SaleAddCatalogues(sale=sale)
@@ -290,12 +291,12 @@ class SaleRemoveCatalogues(SaleBaseCatalogueMutation):
description = 'Removes products, categories, collections from a sale.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('discount.manage_discounts')
@classmethod
- def perform_mutation(cls, root, info, id, input):
+ def perform_mutation(cls, _root, info, **data):
sale = cls.get_node_or_error(
- info, id, only_type=Sale, field='sale_id')
- cls.remove_catalogues_from_node(sale, input)
+ info, data.get('id'), only_type=Sale, field='sale_id')
+ cls.remove_catalogues_from_node(sale, data.get('input'))
return SaleRemoveCatalogues(sale=sale)
diff --git a/saleor/graphql/menu/bulk_mutations.py b/saleor/graphql/menu/bulk_mutations.py
index 9eda9527c8..93492f5240 100644
--- a/saleor/graphql/menu/bulk_mutations.py
+++ b/saleor/graphql/menu/bulk_mutations.py
@@ -16,7 +16,7 @@ class MenuBulkDelete(ModelBulkDeleteMutation):
model = models.Menu
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@@ -32,5 +32,5 @@ class MenuItemBulkDelete(ModelBulkDeleteMutation):
model = models.MenuItem
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.py
index 7638275c1a..b7d6595c31 100644
--- a/saleor/graphql/menu/mutations.py
+++ b/saleor/graphql/menu/mutations.py
@@ -53,12 +53,12 @@ class MenuCreate(ModelMutation):
model = models.Menu
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
items = []
for item in cleaned_input.get('items', []):
category = item.get('category')
@@ -108,7 +108,7 @@ class MenuUpdate(ModelMutation):
model = models.Menu
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@@ -122,7 +122,7 @@ class MenuDelete(ModelDeleteMutation):
model = models.Menu
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@@ -139,12 +139,12 @@ class MenuItemCreate(ModelMutation):
model = models.MenuItem
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
items = [
cleaned_input.get('page'), cleaned_input.get('collection'),
cleaned_input.get('url'), cleaned_input.get('category')]
@@ -169,7 +169,7 @@ class MenuItemUpdate(MenuItemCreate):
model = models.MenuItem
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@classmethod
@@ -192,7 +192,7 @@ class MenuItemDelete(ModelDeleteMutation):
model = models.MenuItem
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('menu.manage_menus')
@@ -209,12 +209,12 @@ class AssignNavigation(BaseMutation):
description = 'Assigns storefront\'s navigation menus.'
@classmethod
- def user_is_allowed(cls, instance, input):
+ def user_is_allowed(cls, instance, _data):
return instance.has_perms([
'menu.manage_menus', 'site.manage_settings'])
@classmethod
- def perform_mutation(cls, root, info, navigation_type, menu=None):
+ def perform_mutation(cls, _root, info, navigation_type, menu=None):
site_settings = info.context.site.settings
if menu is not None:
menu = cls.get_node_or_error(info, menu, field='menu')
diff --git a/saleor/graphql/order/bulk_mutations/draft_orders.py b/saleor/graphql/order/bulk_mutations/draft_orders.py
index cdb11c40ba..b10388338e 100644
--- a/saleor/graphql/order/bulk_mutations/draft_orders.py
+++ b/saleor/graphql/order/bulk_mutations/draft_orders.py
@@ -22,7 +22,7 @@ class DraftOrderBulkDelete(ModelBulkDeleteMutation):
raise ValidationError({'id': 'Cannot delete non-draft orders.'})
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.py
index e68e8bb43f..0ade52dbdf 100644
--- a/saleor/graphql/order/mutations/draft_orders.py
+++ b/saleor/graphql/order/mutations/draft_orders.py
@@ -64,12 +64,12 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
model = models.Order
@classmethod
- def clean_input(cls, info, instance, input):
+ def clean_input(cls, info, instance, raw_input):
shipping_address = input.pop('shipping_address', None)
billing_address = input.pop('billing_address', None)
- cleaned_input = super().clean_input(info, instance, input)
+ cleaned_input = super().clean_input(info, instance, raw_input)
- lines = input.pop('lines', None)
+ lines = raw_input.pop('lines', None)
if lines:
variant_ids = [line.get('variant_id') for line in lines]
variants = cls.get_nodes_or_error(
@@ -102,7 +102,7 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
return cleaned_input
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
@@ -150,7 +150,7 @@ class DraftOrderDelete(ModelDeleteMutation):
model = models.Order
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@@ -232,17 +232,17 @@ class DraftOrderLinesCreate(BaseMutation):
description = 'Create order lines for a draft order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, _root, info, **data):
+ order = cls.get_node_or_error(info, data.get('id'), only_type=Order)
if order.status != OrderStatus.DRAFT:
raise ValidationError({'id': 'Only draft orders can be edited.'})
lines = []
- for input_line in input:
+ for input_line in data.get('input'):
variant_id = input_line['variant_id']
variant = cls.get_node_or_error(
info, variant_id, 'variant_id', only_type=ProductVariant)
@@ -274,7 +274,7 @@ class DraftOrderLineDelete(BaseMutation):
description = 'Deletes an order line from a draft order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
@@ -306,16 +306,16 @@ class DraftOrderLineUpdate(ModelMutation):
model = models.OrderLine
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
if instance.order.status != OrderStatus.DRAFT:
raise ValidationError({'id': 'Only draft orders can be edited.'})
- quantity = input['quantity']
+ quantity = raw_input['quantity']
if quantity <= 0:
raise ValidationError({
'quantity':
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index d44a171ad5..356ddd15f5 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -80,8 +80,8 @@ class FulfillmentCreate(BaseMutation):
raise ValidationError({'order_line_id': msg})
@classmethod
- def clean_input(cls, input):
- lines = input['lines']
+ def clean_input(cls, raw_input):
+ lines = raw_input['lines']
quantities = [line['quantity'] for line in lines]
lines_ids = [line['order_line_id'] for line in lines]
order_lines = cls.get_nodes_or_error(
@@ -93,9 +93,9 @@ class FulfillmentCreate(BaseMutation):
raise ValidationError({
'lines': 'Total quantity must be larger than 0.'})
- input['order_lines'] = order_lines
- input['quantities'] = quantities
- return input
+ raw_input['order_lines'] = order_lines
+ raw_input['quantities'] = quantities
+ return raw_input
@classmethod
def save(cls, user, fulfillment, order, cleaned_input):
@@ -124,17 +124,18 @@ class FulfillmentCreate(BaseMutation):
return fulfillment
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, order, input):
+ def perform_mutation(cls, root, info, order, **data):
order = cls.get_node_or_error(
info, order, field='order', only_type=Order)
+ raw_input = data.get('input')
fulfillment = models.Fulfillment(
- tracking_number=input.pop('tracking_number', None) or '',
+ tracking_number=raw_input.pop('tracking_number', None) or '',
order=order)
- cleaned_input = cls.clean_input(input)
+ cleaned_input = cls.clean_input(raw_input)
fulfillment = cls.save(
info.context.user, fulfillment, order, cleaned_input)
return FulfillmentCreate(
@@ -158,13 +159,14 @@ class FulfillmentUpdateTracking(BaseMutation):
description = 'Updates a fulfillment for an order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- fulfillment = cls.get_node_or_error(info, id, only_type=Fulfillment)
- tracking_number = input.get('tracking_number') or ''
+ def perform_mutation(cls, _root, info, **data):
+ fulfillment = cls.get_node_or_error(
+ info, data.get('id'), only_type=Fulfillment)
+ tracking_number = data.get('input').get('tracking_number') or ''
fulfillment.tracking_number = tracking_number
fulfillment.save()
order = fulfillment.order
@@ -199,9 +201,10 @@ class FulfillmentCancel(BaseMutation):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- restock = input.get('restock')
- fulfillment = cls.get_node_or_error(info, id, only_type=Fulfillment)
+ def perform_mutation(cls, _root, info, **data):
+ restock = data.get('input').get('restock')
+ fulfillment = cls.get_node_or_error(
+ info, data.get('id'), only_type=Fulfillment)
if not fulfillment.can_edit():
err_msg = pgettext_lazy(
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 2ccd0a5007..5990375189 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -114,14 +114,16 @@ class OrderUpdateShipping(BaseMutation):
description = 'Updates a shipping method of the order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, _root, info, **data):
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
+ raw_input = data.get('input')
- if not input['shipping_method']:
+ if not raw_input['shipping_method']:
if not order.is_draft() and order.is_shipping_required():
raise ValidationError({
'shipping_method':
@@ -137,7 +139,7 @@ class OrderUpdateShipping(BaseMutation):
return OrderUpdateShipping(order=order)
method = cls.get_node_or_error(
- info, input['shipping_method'], field='shipping_method',
+ info, raw_input['shipping_method'], field='shipping_method',
only_type=ShippingMethod)
clean_order_update_shipping(order, method)
@@ -172,17 +174,18 @@ class OrderAddNote(BaseMutation):
description = 'Adds note to the order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, _root, info, **data):
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
event = order.events.create(
type=OrderEvents.NOTE_ADDED.value,
user=info.context.user,
parameters={
- 'message': input['message']})
+ 'message': data.get('input')['message']})
return OrderAddNote(order=order, event=event)
@@ -200,12 +203,13 @@ class OrderCancel(BaseMutation):
description = 'Cancel an order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, restock):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, _root, info, restock, **data):
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
clean_order_cancel(order)
cancel_order(order=order, restock=restock)
if restock:
@@ -230,12 +234,13 @@ class OrderMarkAsPaid(BaseMutation):
description = 'Mark order as manually paid.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, _root, info, **data):
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
try:
clean_mark_order_as_paid(order)
except PaymentError as e:
@@ -257,16 +262,17 @@ class OrderCapture(BaseMutation):
description = 'Capture an order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, amount):
+ def perform_mutation(cls, root, info, amount, **data):
if amount <= 0:
raise ValidationError({
'amount': 'Amount should be a positive number.'})
- order = cls.get_node_or_error(info, id, only_type=Order)
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
payment = order.get_last_payment()
clean_order_capture(payment, amount)
@@ -293,12 +299,13 @@ class OrderVoid(BaseMutation):
description = 'Void an order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id):
- order = cls.get_node_or_error(info, id, only_type=Order)
+ def perform_mutation(cls, root, info, **data):
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
payment = order.get_last_payment()
clean_void_payment(payment)
try:
@@ -324,16 +331,17 @@ class OrderRefund(BaseMutation):
description = 'Refund an order.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, id, amount):
+ def perform_mutation(cls, root, info, amount, **data):
if amount <= 0:
raise ValidationError({
'amount': 'Amount should be a positive number.'})
- order = cls.get_node_or_error(info, id, only_type=Order)
+ order = cls.get_node_or_error(
+ info, data.get('id'), only_type=Order)
payment = order.get_last_payment()
clean_refund_payment(payment, amount)
diff --git a/saleor/graphql/page/bulk_mutations.py b/saleor/graphql/page/bulk_mutations.py
index b3a15d2fb9..35f273f98a 100644
--- a/saleor/graphql/page/bulk_mutations.py
+++ b/saleor/graphql/page/bulk_mutations.py
@@ -16,7 +16,7 @@ class PageBulkDelete(ModelBulkDeleteMutation):
model = models.Page
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('page.manage_pages')
diff --git a/saleor/graphql/page/mutations.py b/saleor/graphql/page/mutations.py
index 41e99b943c..b418f2f606 100644
--- a/saleor/graphql/page/mutations.py
+++ b/saleor/graphql/page/mutations.py
@@ -32,12 +32,12 @@ class PageCreate(ModelMutation):
model = models.Page
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('page.manage_pages')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
slug = cleaned_input.get('slug', '')
if not slug:
cleaned_input['slug'] = slugify(cleaned_input['title'])
@@ -65,5 +65,5 @@ class PageDelete(ModelDeleteMutation):
model = models.Page
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('page.manage_pages')
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.py
index c436ef3274..147e7936a8 100644
--- a/saleor/graphql/payment/mutations.py
+++ b/saleor/graphql/payment/mutations.py
@@ -54,13 +54,14 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
description = 'Create a new payment for given checkout.'
@classmethod
- def perform_mutation(cls, root, info, checkout_id, input):
+ def perform_mutation(cls, _root, info, checkout_id, **data):
checkout = cls.get_node_or_error(
info, checkout_id, field='checkout_id', only_type=Checkout)
+ raw_input = data.get('input')
billing_address = checkout.billing_address
- if 'billing_address' in input:
- billing_address = cls.validate_address(input['billing_address'])
+ if 'billing_address' in raw_input:
+ billing_address = cls.validate_address(raw_input['billing_address'])
if billing_address is None:
raise ValidationError({
'billing_address':
@@ -69,7 +70,7 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
checkout_total = checkout.get_total(
discounts=info.context.discounts,
taxes=get_taxes_for_address(checkout.billing_address))
- amount = input.get('amount', checkout_total)
+ amount = raw_input.get('amount', checkout_total)
if amount < checkout_total.gross.amount:
raise ValidationError({
'amount':
@@ -80,8 +81,8 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
'customer_user_agent': info.context.META.get('HTTP_USER_AGENT')}
payment = create_payment(
- gateway=input['gateway'],
- payment_token=input['token'],
+ gateway=raw_input['gateway'],
+ payment_token=raw_input['token'],
total=amount,
currency=settings.DEFAULT_CURRENCY,
email=checkout.email,
@@ -147,11 +148,11 @@ class PaymentVoid(BaseMutation):
description = 'Voids the authorized payment'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
- def perform_mutation(cls, root, info, payment_id, amount=None):
+ def perform_mutation(cls, _root, info, payment_id):
payment = cls.get_node_or_error(
info, payment_id, field='payment_id', only_type=Payment)
try:
diff --git a/saleor/graphql/product/bulk_mutations/attributes.py b/saleor/graphql/product/bulk_mutations/attributes.py
index 91127f8396..4fac1cc9a7 100644
--- a/saleor/graphql/product/bulk_mutations/attributes.py
+++ b/saleor/graphql/product/bulk_mutations/attributes.py
@@ -16,7 +16,7 @@ class AttributeBulkDelete(ModelBulkDeleteMutation):
model = models.Attribute
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -32,5 +32,5 @@ class AttributeValueBulkDelete(ModelBulkDeleteMutation):
model = models.AttributeValue
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
diff --git a/saleor/graphql/product/bulk_mutations/products.py b/saleor/graphql/product/bulk_mutations/products.py
index 2c15e3378c..8ac28bcf0a 100644
--- a/saleor/graphql/product/bulk_mutations/products.py
+++ b/saleor/graphql/product/bulk_mutations/products.py
@@ -16,7 +16,7 @@ class CategoryBulkDelete(ModelBulkDeleteMutation):
model = models.Category
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -32,7 +32,7 @@ class CollectionBulkDelete(ModelBulkDeleteMutation):
model = models.Collection
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -48,7 +48,7 @@ class ProductBulkDelete(ModelBulkDeleteMutation):
model = models.Product
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -64,7 +64,7 @@ class ProductVariantBulkDelete(ModelBulkDeleteMutation):
model = models.ProductVariant
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -80,7 +80,7 @@ class ProductTypeBulkDelete(ModelBulkDeleteMutation):
model = models.ProductType
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -96,5 +96,5 @@ class ProductImageBulkDelete(ModelBulkDeleteMutation):
model = models.ProductImage
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index 144023ea23..81aa1fd9fc 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -140,11 +140,13 @@ class AttributeCreate(AttributeMixin, ModelMutation):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, id, type, input):
- product_type = cls.get_node_or_error(info, id, only_type=ProductType)
+ @permission_required('product.manage_products')
+ def mutate(cls, _root, info, **data):
+ product_type = cls.get_node_or_error(
+ info, data.get('id'), only_type=ProductType)
instance = models.Attribute()
- cleaned_input = cls.clean_input(info, instance, input)
+ cleaned_input = cls.clean_input(info, instance, data.get('input'))
cls.clean_attribute(
instance, cleaned_input, product_type=product_type)
cls.clean_values(cleaned_input, instance)
@@ -152,7 +154,7 @@ class AttributeCreate(AttributeMixin, ModelMutation):
cls.clean_instance(instance)
instance.save()
- if type == AttributeTypeEnum.VARIANT.name:
+ if data.get('type') == AttributeTypeEnum.VARIANT.name:
product_type.variant_attributes.add(instance)
else:
product_type.product_attributes.add(instance)
@@ -231,7 +233,7 @@ class AttributeDelete(ModelDeleteMutation):
model = models.Attribute
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
@@ -258,8 +260,8 @@ class AttributeValueCreate(ModelMutation):
model = models.AttributeValue
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
cleaned_input['slug'] = slugify(cleaned_input['name'])
return cleaned_input
@@ -299,12 +301,12 @@ class AttributeValueUpdate(ModelMutation):
model = models.AttributeValue
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
if 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
return cleaned_input
@@ -327,7 +329,7 @@ class AttributeValueDelete(ModelDeleteMutation):
model = models.AttributeValue
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
diff --git a/saleor/graphql/product/mutations/digital_contents.py b/saleor/graphql/product/mutations/digital_contents.py
index a555b19893..c6bf704699 100644
--- a/saleor/graphql/product/mutations/digital_contents.py
+++ b/saleor/graphql/product/mutations/digital_contents.py
@@ -56,45 +56,45 @@ class DigitalContentCreate(BaseMutation):
@classmethod
@permission_required('product.manage_products')
- def clean_input(cls, info, input, instance):
+ def clean_input(cls, info, raw_input, instance):
if hasattr(instance, 'digital_content'):
instance.digital_content.delete()
- use_default_settings = input.get('use_default_settings')
+ use_default_settings = raw_input.get('use_default_settings')
if use_default_settings:
- return input
+ return raw_input
required_fields = [
'max_downloads', 'url_valid_days', 'automatic_fulfillment']
- if not all(field in input for field in required_fields):
+ if not all(field in raw_input for field in required_fields):
msg = ('Use default settings is disabled. Provide all '
'missing configuration fields: ')
- missing_fields = set(required_fields).difference(set(input))
+ missing_fields = set(required_fields).difference(set(raw_input))
if missing_fields:
msg += '{}, ' * len(missing_fields)
raise ValidationError(msg.format(*missing_fields))
- return input
+ return raw_input
@classmethod
@permission_required('product.manage_products')
- def perform_mutation(cls, root, info, variant_id, input):
+ def perform_mutation(cls, _root, info, variant_id, **data):
variant = cls.get_node_or_error(
info, variant_id, 'id', only_type=ProductVariant)
- input = cls.clean_input(info, input, variant)
+ clean_input = cls.clean_input(info, data.get('input'), variant)
- content_data = info.context.FILES.get(input['content_file'])
+ content_data = info.context.FILES.get(clean_input['content_file'])
digital_content = models.DigitalContent(
content_file=content_data
)
- digital_content.use_default_settings = input.get(
+ digital_content.use_default_settings = clean_input.get(
'use_default_settings', False)
- digital_content.max_downloads = input.get('max_downloads')
- digital_content.url_valid_days = input.get('url_valid_days')
- digital_content.automatic_fulfillment = input.get(
+ digital_content.max_downloads = clean_input.get('max_downloads')
+ digital_content.url_valid_days = clean_input.get('url_valid_days')
+ digital_content.automatic_fulfillment = clean_input.get(
'automatic_fulfillment', False)
variant.digital_content = digital_content
@@ -118,7 +118,7 @@ class DigitalContentDelete(BaseMutation):
@classmethod
@permission_required('product.manage_products')
- def mutate(cls, root, info, variant_id):
+ def mutate(cls, _root, info, variant_id):
variant = cls.get_node_or_error(
info, variant_id, 'id', only_type=ProductVariant)
@@ -146,27 +146,27 @@ class DigitalContentUpdate(BaseMutation):
@classmethod
@permission_required('product.manage_products')
- def clean_input(cls, info, input):
- use_default_settings = input.get('use_default_settings')
+ def clean_input(cls, info, raw_input):
+ use_default_settings = raw_input.get('use_default_settings')
if use_default_settings:
return {'use_default_settings': use_default_settings}
required_fields = [
'max_downloads', 'url_valid_days', 'automatic_fulfillment']
- if not all(field in input for field in required_fields):
+ if not all(field in raw_input for field in required_fields):
msg = ('Use default settings is disabled. Provide all '
'missing configuration fields: ')
- missing_fields = set(required_fields).difference(set(input))
+ missing_fields = set(required_fields).difference(set(raw_input))
if missing_fields:
msg += '{}, ' * len(missing_fields)
raise ValidationError(msg.format(*missing_fields))
- return input
+ return raw_input
@classmethod
@permission_required('product.manage_products')
- def perform_mutation(cls, root, info, variant_id, input):
+ def perform_mutation(cls, root, info, variant_id, **data):
variant = cls.get_node_or_error(
info, variant_id, 'id', only_type=ProductVariant)
@@ -174,16 +174,16 @@ class DigitalContentUpdate(BaseMutation):
msg = 'Variant %s doesn\'t have any digital content' % variant.id
raise ValidationError({'variantId': msg})
- input = cls.clean_input(info, input)
+ clean_input = cls.clean_input(info, data.get('input'))
digital_content = variant.digital_content
- digital_content.use_default_settings = input.get(
+ digital_content.use_default_settings = clean_input.get(
'use_default_settings', False)
- digital_content.max_downloads = input.get('max_downloads')
- digital_content.url_valid_days = input.get('url_valid_days')
- digital_content.automatic_fulfillment = input.get(
+ digital_content.max_downloads = clean_input.get('max_downloads')
+ digital_content.url_valid_days = clean_input.get('url_valid_days')
+ digital_content.automatic_fulfillment = clean_input.get(
'automatic_fulfillment', False)
variant.digital_content = digital_content
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 9b767b1904..4277090090 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -48,23 +48,23 @@ class CategoryCreate(ModelMutation):
model = models.Category
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
if 'slug' not in cleaned_input and 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
- parent_id = input['parent_id']
+ parent_id = raw_input['parent_id']
if parent_id:
parent = cls.get_node_or_error(
info, parent_id, field='parent', only_type=Category)
cleaned_input['parent'] = parent
- if input.get('background_image'):
- image_data = info.context.FILES.get(input['background_image'])
+ if raw_input.get('background_image'):
+ image_data = info.context.FILES.get(raw_input['background_image'])
validate_image_file(image_data, 'background_image')
clean_seo_fields(cleaned_input)
return cleaned_input
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
@@ -108,7 +108,7 @@ class CategoryDelete(ModelDeleteMutation):
model = models.Category
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -147,16 +147,16 @@ class CollectionCreate(ModelMutation):
model = models.Collection
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
if 'slug' not in cleaned_input and 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
- if input.get('background_image'):
- image_data = info.context.FILES.get(input['background_image'])
+ if raw_input.get('background_image'):
+ image_data = info.context.FILES.get(raw_input['background_image'])
validate_image_file(image_data, 'background_image')
clean_seo_fields(cleaned_input)
return cleaned_input
@@ -197,7 +197,7 @@ class CollectionDelete(ModelDeleteMutation):
model = models.Collection
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -218,11 +218,11 @@ class CollectionAddProducts(BaseMutation):
description = 'Adds products to a collection.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, collection_id, products):
+ def perform_mutation(cls, _root, info, collection_id, products):
collection = cls.get_node_or_error(
info, collection_id, field='collection_id', only_type=Collection)
products = cls.get_nodes_or_error(products, 'products', Product)
@@ -245,11 +245,11 @@ class CollectionRemoveProducts(BaseMutation):
description = 'Remove products from a collection.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, collection_id, products):
+ def perform_mutation(cls, _root, info, collection_id, products):
collection = cls.get_node_or_error(
info, collection_id, field='collection_id', only_type=Collection)
products = cls.get_nodes_or_error(
@@ -321,8 +321,8 @@ class ProductCreate(ModelMutation):
model = models.Product
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
# Attributes are provided as list of `AttributeValueInput` objects.
# We need to transform them into the format they're stored in the
# `Product` model, which is HStore field that maps attribute's PK to
@@ -383,7 +383,7 @@ class ProductCreate(ModelMutation):
instance.collections.set(collections)
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -437,7 +437,7 @@ class ProductDelete(ModelDeleteMutation):
model = models.Product
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -492,15 +492,15 @@ class ProductVariantCreate(ModelMutation):
fieldname: 'This field cannot be blank.'})
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
# Attributes are provided as list of `AttributeValueInput` objects.
# We need to transform them into the format they're stored in the
# `Product` model, which is HStore field that maps attribute's PK to
# the value's PK.
- if 'attributes' in input:
+ if 'attributes' in raw_input:
attributes_input = cleaned_input.pop('attributes')
product = instance.product if instance.pk else cleaned_input.get(
'product')
@@ -525,7 +525,7 @@ class ProductVariantCreate(ModelMutation):
instance.save()
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -552,7 +552,7 @@ class ProductVariantDelete(ModelDeleteMutation):
model = models.ProductVariant
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -593,7 +593,7 @@ class ProductTypeCreate(ModelMutation):
model = models.ProductType
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
@@ -637,7 +637,7 @@ class ProductTypeDelete(ModelDeleteMutation):
model = models.ProductType
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@@ -666,18 +666,19 @@ class ProductImageCreate(BaseMutation):
https://github.com/jaydenseric/graphql-multipart-request-spec''')
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, input):
+ def perform_mutation(cls, _root, info, **data):
+ raw_input = data.get('input')
product = cls.get_node_or_error(
- info, input['product'], field='product', only_type=Product)
- image_data = info.context.FILES.get(input['image'])
+ info, raw_input['product'], field='product', only_type=Product)
+ image_data = info.context.FILES.get(raw_input['image'])
validate_image_file(image_data, 'image')
image = product.images.create(
- image=image_data, alt=input.get('alt', ''))
+ image=image_data, alt=raw_input.get('alt', ''))
create_product_thumbnails.delay(image.pk)
return ProductImageCreate(product=product, image=image)
@@ -701,14 +702,15 @@ class ProductImageUpdate(BaseMutation):
description = 'Updates a product image.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, id, input):
- image = cls.get_node_or_error(info, id, only_type=ProductImage)
+ def perform_mutation(cls, _root, info, **data):
+ image = cls.get_node_or_error(
+ info, data.get('id'), only_type=ProductImage)
product = image.product
- alt = input.get('alt')
+ alt = data.get('input').get('alt')
if alt is not None:
image.alt = alt
image.save(update_fields=['alt'])
@@ -731,11 +733,11 @@ class ProductImageReorder(BaseMutation):
description = 'Changes ordering of the product image.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, product_id, images_ids):
+ def perform_mutation(cls, _root, info, product_id, images_ids):
product = cls.get_node_or_error(
info, product_id, field='product_id', only_type=Product)
if len(images_ids) != product.images.count():
@@ -773,12 +775,13 @@ class ProductImageDelete(BaseMutation):
description = 'Deletes a product image.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, id):
- image = cls.get_node_or_error(info, id, only_type=ProductImage)
+ def perform_mutation(cls, _root, info, **data):
+ image = cls.get_node_or_error(
+ info, data.get('id'), only_type=ProductImage)
image_id = image.id
image.delete()
image.id = image_id
@@ -802,11 +805,11 @@ class VariantImageAssign(BaseMutation):
description = 'Assign an image to a product variant'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, image_id, variant_id):
+ def perform_mutation(cls, _root, info, image_id, variant_id):
image = cls.get_node_or_error(
info, image_id, field='image_id', only_type=ProductImage)
variant = cls.get_node_or_error(
@@ -839,11 +842,11 @@ class VariantImageUnassign(BaseMutation):
description = 'Unassign an image from a product variant'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('product.manage_products')
@classmethod
- def perform_mutation(cls, root, info, image_id, variant_id):
+ def perform_mutation(cls, _root, info, image_id, variant_id):
image = cls.get_node_or_error(
info, image_id, field='image_id', only_type=ProductImage)
variant = cls.get_node_or_error(
diff --git a/saleor/graphql/shipping/bulk_mutations.py b/saleor/graphql/shipping/bulk_mutations.py
index 10cbbff730..1245b4b036 100644
--- a/saleor/graphql/shipping/bulk_mutations.py
+++ b/saleor/graphql/shipping/bulk_mutations.py
@@ -16,7 +16,7 @@ class ShippingZoneBulkDelete(ModelBulkDeleteMutation):
model = models.ShippingZone
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@@ -32,5 +32,5 @@ class ShippingPriceBulkDelete(ModelBulkDeleteMutation):
model = models.ShippingMethod
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.py
index 7bb84df265..10795d7630 100644
--- a/saleor/graphql/shipping/mutations.py
+++ b/saleor/graphql/shipping/mutations.py
@@ -44,8 +44,8 @@ class ShippingZoneInput(graphene.InputObjectType):
class ShippingZoneMixin:
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
default = cleaned_input.get('default')
if default:
if default_shipping_zone_exists(instance.pk):
@@ -72,7 +72,7 @@ class ShippingZoneCreate(ShippingZoneMixin, ModelMutation):
model = models.ShippingZone
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@@ -92,7 +92,7 @@ class ShippingZoneUpdate(ShippingZoneMixin, ModelMutation):
model = models.ShippingZone
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@@ -106,14 +106,14 @@ class ShippingZoneDelete(ModelDeleteMutation):
model = models.ShippingZone
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
class ShippingPriceMixin:
@classmethod
- def clean_input(cls, info, instance, input):
- cleaned_input = super().clean_input(info, instance, input)
+ def clean_input(cls, info, instance, raw_input):
+ cleaned_input = super().clean_input(info, instance, raw_input)
type = cleaned_input.get('type')
if type:
if type == ShippingMethodTypeEnum.PRICE.value:
@@ -152,7 +152,7 @@ class ShippingPriceCreate(ShippingPriceMixin, ModelMutation):
model = models.ShippingMethod
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@classmethod
@@ -179,7 +179,7 @@ class ShippingPriceUpdate(ShippingPriceMixin, ModelMutation):
model = models.ShippingMethod
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@classmethod
@@ -204,13 +204,13 @@ class ShippingPriceDelete(BaseMutation):
description = 'Deletes a shipping price.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('shipping.manage_shipping')
@classmethod
- def perform_mutation(cls, root, info, id):
+ def perform_mutation(cls, _root, info, **data):
shipping_method = cls.get_node_or_error(
- info, id, only_type=ShippingMethod)
+ info, data.get('id'), only_type=ShippingMethod)
shipping_method_id = shipping_method.id
shipping_zone = shipping_method.shipping_zone
shipping_method.delete()
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index 3948181d51..2c34704f84 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -48,13 +48,14 @@ class ShopSettingsUpdate(BaseMutation):
description = 'Updates shop settings'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info, input):
+ def perform_mutation(cls, _root, info, **data):
instance = info.context.site.settings
- for field_name, desired_value in input.items():
+ raw_input = data.get('input')
+ for field_name, desired_value in raw_input.items():
current_value = getattr(instance, field_name)
if current_value != desired_value:
setattr(instance, field_name, desired_value)
@@ -73,14 +74,15 @@ class ShopDomainUpdate(BaseMutation):
description = 'Updates site domain of the shop'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info, input):
+ def perform_mutation(cls, _root, info, **data):
site = info.context.site
- domain = input.get('domain')
- name = input.get('name')
+ raw_input = data.get('input')
+ domain = raw_input.get('domain')
+ name = raw_input.get('name')
if domain is not None:
site.domain = domain
if name is not None:
@@ -97,11 +99,11 @@ class ShopFetchTaxRates(BaseMutation):
description = 'Fetch tax rates'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info):
+ def perform_mutation(cls, _root, _info):
if not settings.VATLAYER_ACCESS_KEY:
raise ValidationError(
'Could not fetch tax rates. Make sure you have supplied a '
@@ -121,11 +123,11 @@ class HomepageCollectionUpdate(BaseMutation):
description = 'Updates homepage collection of the shop'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info, collection=None):
+ def perform_mutation(cls, _root, info, collection=None):
new_collection = cls.get_node_or_error(
info, collection, field='collection', only_type=Collection)
site_settings = info.context.site.settings
@@ -158,18 +160,18 @@ class AuthorizationKeyAdd(BaseMutation):
description='Fields required to create an authorization key.')
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info, key_type, input):
+ def perform_mutation(cls, _root, info, key_type, **data):
if site_models.AuthorizationKey.objects.filter(name=key_type).exists():
raise ValidationError({
'key_type': 'Authorization key already exists.'})
site_settings = info.context.site.settings
instance = site_models.AuthorizationKey(
- name=key_type, site_settings=site_settings, **input)
+ name=key_type, site_settings=site_settings, **data.get('input'))
cls.clean_instance(instance)
instance.save()
return AuthorizationKeyAdd(authorization_key=instance, shop=Shop())
@@ -188,11 +190,11 @@ class AuthorizationKeyDelete(BaseMutation):
description = 'Deletes an authorization key.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_settings')
@classmethod
- def perform_mutation(cls, root, info, key_type):
+ def perform_mutation(cls, _root, info, key_type):
try:
site_settings = info.context.site.settings
instance = site_models.AuthorizationKey.objects.get(
diff --git a/saleor/graphql/translations/mutations.py b/saleor/graphql/translations/mutations.py
index e2ba9fd070..ff1ed8913b 100644
--- a/saleor/graphql/translations/mutations.py
+++ b/saleor/graphql/translations/mutations.py
@@ -214,12 +214,12 @@ class ShopSettingsTranslate(BaseMutation):
description = 'Creates/Updates translations for Shop Settings.'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('site.manage_translations')
@classmethod
- def perform_mutation(cls, root, info, language_code, input):
+ def perform_mutation(cls, _root, info, language_code, **data):
instance = info.context.site.settings
instance.translations.update_or_create(
- language_code=language_code, defaults=input)
+ language_code=language_code, defaults=data.get('input'))
return ShopSettingsTranslate(shop=Shop())
diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.py
index bad9918446..4d51ba76ca 100644
--- a/saleor/graphql/utils.py
+++ b/saleor/graphql/utils.py
@@ -1,10 +1,11 @@
+from typing import List
+
import graphene
from django.db.models import Q
from django.utils import timezone
from graphene_django.registry import get_global_registry
from graphql.error import GraphQLError
from graphql_relay import from_global_id
-from typing import List
from .core.enums import PermissionEnum, ReportingPeriod
from .core.types import PermissionDisplay
@@ -53,7 +54,7 @@ def _resolve_graphene_type(types: List):
assert len(set(types)) == 1, 'Received IDs of more than one type.'
# get type by name
type_name = types[0]
- for model, _type in registry._registry.items():
+ for _, _type in registry._registry.items():
if _type._meta.name == type_name:
return _type
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 5c72c1bc33..90f030474d 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -7,7 +7,7 @@ from django.shortcuts import render_to_response
from django.views.generic import View
from graphene_django.settings import graphene_settings
from graphene_django.views import instantiate_middleware
-from graphql import get_default_backend, GraphQLDocument
+from graphql import GraphQLDocument, get_default_backend
from graphql.error import (
GraphQLError, GraphQLSyntaxError, format_error as format_graphql_error)
from graphql.execution import ExecutionResult
diff --git a/tests/api/test_order.py b/tests/api/test_order.py
index e92fad3f39..d8db70d373 100644
--- a/tests/api/test_order.py
+++ b/tests/api/test_order.py
@@ -937,8 +937,8 @@ def test_order_add_note(
mutation addNote($id: ID!, $message: String) {
orderAddNote(order: $id, input: {message: $message}) {
errors {
- field
- message
+ field
+ message
}
order {
id