Skip to content

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

Remove few shadow names, many unused arguments and typos

NyanKiyoshie18c3f94bfea
diff --git a/saleor/graphql/account/fields.py b/saleor/graphql/account/fields.py
index fc476b5d4d..91ac425c7e 100644
--- a/saleor/graphql/account/fields.py
+++ b/saleor/graphql/account/fields.py
@@ -5,5 +5,5 @@ from ...account.models import PossiblePhoneNumberField
@convert_django_field.register(PossiblePhoneNumberField)
-def convert_json_field_to_string(field, registry=None):
+def convert_json_field_to_string(*_args):
return graphene.String()
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index 01904cd55b..c22c686be8 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -507,7 +507,7 @@ class AddressDelete(ModelDeleteMutation):
# Refresh the user instance to clear the default addresses. If the
# deleted address was used as default, it would stay cached in the
- # user instance and the invalid ID returned in the response migt cause
+ # user instance and the invalid ID returned in the response might cause
# an error.
user.refresh_from_db()
@@ -520,12 +520,14 @@ class AddressSetDefault(BaseMutation):
class Arguments:
address_id = graphene.ID(
- required=True, description='ID of the address.')
+ required=True,
+ description='ID of the address.')
user_id = graphene.ID(
required=True,
description='ID of the user to change the address for.')
type = AddressTypeEnum(
- required=True, description='The type of address.')
+ required=True,
+ description='The type of address.')
class Meta:
description = 'Sets a default address for the given user.'
@@ -594,7 +596,7 @@ class CustomerAddressCreate(ModelMutation):
instance.user_addresses.add(user)
-# The same as SetDefaultAddress, but for the currenty authenticated user.
+# The same as SetDefaultAddress, but for the currently authenticated user.
class CustomerSetDefaultAddress(BaseMutation):
user = graphene.Field(User, description='An updated user instance.')
@@ -621,6 +623,7 @@ class CustomerSetDefaultAddress(BaseMutation):
'id': 'The address doesn\'t belong to that user.'})
raw_address_type = data.get('type')
+ address_type = None
if raw_address_type == AddressTypeEnum.BILLING.value:
address_type = AddressType.BILLING
elif raw_address_type == AddressTypeEnum.SHIPPING.value:
diff --git a/saleor/graphql/account/schema.py b/saleor/graphql/account/schema.py
index 59ba4055c2..1d49b94e43 100644
--- a/saleor/graphql/account/schema.py
+++ b/saleor/graphql/account/schema.py
@@ -35,7 +35,7 @@ class AccountQueries(graphene.ObjectType):
return resolve_address_validator(info, input)
@permission_required('account.manage_users')
- def resolve_customers(self, info, query=None, **kwargs):
+ def resolve_customers(self, info, query=None, **_kwargs):
return resolve_customers(info, query=query)
@login_required
@@ -43,7 +43,7 @@ class AccountQueries(graphene.ObjectType):
return info.context.user
@permission_required('account.manage_staff')
- def resolve_staff_users(self, info, query=None, **kwargs):
+ def resolve_staff_users(self, info, query=None, **_kwargs):
return resolve_staff_users(info, query=query)
@permission_required('account.manage_users')
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.py
index a1487c0ba1..e7b7bf597e 100644
--- a/saleor/graphql/account/types.py
+++ b/saleor/graphql/account/types.py
@@ -47,11 +47,11 @@ class Address(CountableDjangoObjectType):
'first_name', 'id', 'last_name', 'phone', 'postal_code',
'street_address_1', 'street_address_2']
- def resolve_country(self, info):
+ def resolve_country(self, _info):
return CountryDisplay(
code=self.country.code, country=self.country.name)
- def resolve_is_default_shipping_address(self, info):
+ def resolve_is_default_shipping_address(self, _info):
"""
This field is added through annotation when using the
`resolve_addresses` resolver. It's invalid for
@@ -67,7 +67,7 @@ class Address(CountableDjangoObjectType):
return True
return False
- def resolve_is_default_billing_address(self, info):
+ def resolve_is_default_billing_address(self, _info):
"""
This field is added through annotation when using the
`resolve_addresses` resolver. It's invalid for
@@ -112,13 +112,13 @@ class User(CountableDjangoObjectType):
'is_active', 'is_staff', 'last_login', 'last_name', 'note',
'token']
- def resolve_addresses(self, info, **kwargs):
+ def resolve_addresses(self, _info, **_kwargs):
return self.addresses.annotate_default(self).all()
- def resolve_checkout(self, info, **kwargs):
+ def resolve_checkout(self, _info, **_kwargs):
return get_user_cart(self)
- def resolve_permissions(self, info, **kwargs):
+ def resolve_permissions(self, _info, **_kwargs):
if self.is_superuser:
permissions = get_permissions()
else:
@@ -127,16 +127,16 @@ class User(CountableDjangoObjectType):
return format_permissions_for_display(permissions)
@permission_required('account.manage_users')
- def resolve_note(self, info):
+ def resolve_note(self, _info):
return self.note
- def resolve_orders(self, info, **kwargs):
+ def resolve_orders(self, info, **_kwargs):
viewer = info.context.user
if viewer.has_perm('order.manage_orders'):
return self.orders.all()
return self.orders.confirmed()
- def resolve_avatar(self, info, size=None, **kwargs):
+ def resolve_avatar(self, info, size=None, **_kwargs):
if self.avatar:
return Image.get_adjusted(
image=self.avatar,
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index f10c7a9a88..bb57f27f27 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -90,7 +90,7 @@ class CheckoutCreateInput(graphene.InputObjectType):
description='The customer\'s email address.')
shipping_address = AddressInput(
description=(
- 'The mailling address to where the checkout will be shipped.'))
+ 'The mailing address to where the checkout will be shipped.'))
billing_address = AddressInput(
description='Billing address of the customer.')
@@ -171,7 +171,7 @@ class CheckoutCreate(ModelMutation, I18nMixin):
def perform_mutation(cls, root, info, **data):
user = info.context.user
- # `perform_mutation` is overriden to properly get or create a checkout
+ # `perform_mutation` is overridden to properly get or create a checkout
# instance here and abort mutation if needed.
if user.is_authenticated:
checkout, created = get_or_create_user_cart(user)
@@ -330,7 +330,7 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):
shipping_address = AddressInput(
required=True,
description=(
- 'The mailling address to where the checkout will be shipped.'))
+ 'The mailing address to where the checkout will be shipped.'))
class Meta:
description = 'Update shipping address in the existing Checkout.'
diff --git a/saleor/graphql/checkout/resolvers.py b/saleor/graphql/checkout/resolvers.py
index afedc7c4ed..39a1d95e6d 100644
--- a/saleor/graphql/checkout/resolvers.py
+++ b/saleor/graphql/checkout/resolvers.py
@@ -1,16 +1,16 @@
from ...checkout import models
-def resolve_checkout_lines(info, query):
+def resolve_checkout_lines():
queryset = models.CartLine.objects.all()
return queryset
-def resolve_checkouts(info, query):
+def resolve_checkouts():
queryset = models.Cart.objects.all()
return queryset
-def resolve_checkout(info, token):
+def resolve_checkout(token):
checkout = models.Cart.objects.filter(token=token).first()
return checkout
diff --git a/saleor/graphql/checkout/schema.py b/saleor/graphql/checkout/schema.py
index c60c4d762d..e44b0e1016 100644
--- a/saleor/graphql/checkout/schema.py
+++ b/saleor/graphql/checkout/schema.py
@@ -28,19 +28,19 @@ class CheckoutQueries(graphene.ObjectType):
checkout_lines = PrefetchingConnectionField(
CheckoutLine, description='List of checkout lines')
- def resolve_checkout(self, info, token):
- return resolve_checkout(info, token)
+ def resolve_checkout(self, *_args, token):
+ return resolve_checkout(token)
@permission_required('order.manage_orders')
- def resolve_checkouts(self, info, query=None, **kwargs):
- resolve_checkouts(info, query)
+ def resolve_checkouts(self, *_args, **_kwargs):
+ resolve_checkouts()
def resolve_checkout_line(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, CheckoutLine)
@permission_required('order.manage_orders')
- def resolve_checkout_lines(self, info, query=None, **kwargs):
- return resolve_checkout_lines(info, query)
+ def resolve_checkout_lines(self, *_args, **_kwargs):
+ return resolve_checkout_lines()
class CheckoutMutations(graphene.ObjectType):
diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.py
index a4f13b091b..f92a934561 100644
--- a/saleor/graphql/checkout/types.py
+++ b/saleor/graphql/checkout/types.py
@@ -30,7 +30,7 @@ class CheckoutLine(CountableDjangoObjectType):
taxes = get_taxes_for_address(self.cart.shipping_address)
return self.get_total(discounts=info.context.discounts, taxes=taxes)
- def resolve_requires_shipping(self, info):
+ def resolve_requires_shipping(self, *_args):
return self.is_shipping_required()
@@ -79,15 +79,15 @@ class Checkout(CountableDjangoObjectType):
taxes = get_taxes_for_address(self.shipping_address)
return self.get_total(discounts=info.context.discounts, taxes=taxes)
- def resolve_subtotal_price(self, info):
+ def resolve_subtotal_price(self, *_args):
taxes = get_taxes_for_address(self.shipping_address)
return self.get_subtotal(taxes=taxes)
- def resolve_shipping_price(self, info):
+ def resolve_shipping_price(self, *_args):
taxes = get_taxes_for_address(self.shipping_address)
return self.get_shipping_price(taxes=taxes)
- def resolve_lines(self, info):
+ def resolve_lines(self, *_args):
return self.lines.prefetch_related('variant')
def resolve_available_shipping_methods(self, info):
@@ -96,8 +96,8 @@ class Checkout(CountableDjangoObjectType):
taxes=taxes, discounts=info.context.discounts)
return applicable_shipping_methods(self, price.gross.amount)
- def resolve_available_payment_gateways(self, info):
+ def resolve_available_payment_gateways(self, _info):
return settings.CHECKOUT_PAYMENT_GATEWAYS.keys()
- def resolve_is_shipping_required(self, info):
+ def resolve_is_shipping_required(self, _info):
return self.is_shipping_required()
diff --git a/saleor/graphql/core/fields.py b/saleor/graphql/core/fields.py
index 2833aefaa7..7a01bd7c08 100644
--- a/saleor/graphql/core/fields.py
+++ b/saleor/graphql/core/fields.py
@@ -12,17 +12,17 @@ from .types.money import Money, TaxedMoney
@convert_django_field.register(TaxedMoneyField)
-def convert_field_taxed_money(field, registry=None):
+def convert_field_taxed_money(*_args):
return graphene.Field(TaxedMoney)
@convert_django_field.register(MoneyField)
-def convert_field_money(field, registry=None):
+def convert_field_money(*_args):
return graphene.Field(Money)
@convert_django_field.register(MeasurementField)
-def convert_field_measurements(field, registry=None):
+def convert_field_measurements(*_args):
return graphene.Field(Weight)
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 7b4423d67c..041c48ade7 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -249,26 +249,26 @@ class ModelMutation(BaseMutation):
return field.type.of_type == Upload
return field.type == Upload
- InputCls = getattr(cls.Arguments, 'input')
+ input_cls = getattr(cls.Arguments, 'input')
cleaned_input = {}
- for field_name, field in InputCls._meta.fields.items():
+ for field_name, field_item in input_cls._meta.fields.items():
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):
+ if value is not None and is_list_of_ids(field_item):
instances = cls.get_nodes_or_error(
value, field_name) if value else []
cleaned_input[field_name] = instances
# handle ID field
- elif value is not None and is_id_field(field):
+ elif value is not None and is_id_field(field_item):
instance = cls.get_node_or_error(info, value, field_name)
cleaned_input[field_name] = instance
# handle uploaded files
- elif value is not None and is_upload_field(field):
+ elif value is not None and is_upload_field(field_item):
value = info.context.FILES.get(value)
cleaned_input[field_name] = value
@@ -322,7 +322,7 @@ class ModelMutation(BaseMutation):
"""Perform model mutation.
Depending on the input data, `mutate` either creates a new instance or
- updates an existing one. If `id` arugment is present, it is assumed
+ updates an existing one. If `id` argument is present, it is assumed
that this is an "update" mutation. Otherwise, a new instance is
created based on the model associated with this mutation.
"""
diff --git a/saleor/graphql/discount/schema.py b/saleor/graphql/discount/schema.py
index 965f63bd10..746cb4b001 100644
--- a/saleor/graphql/discount/schema.py
+++ b/saleor/graphql/discount/schema.py
@@ -33,7 +33,7 @@ class DiscountQueries(graphene.ObjectType):
return graphene.Node.get_node_from_global_id(info, id, Sale)
@permission_required('discount.manage_discounts')
- def resolve_sales(self, info, query=None, **kwargs):
+ def resolve_sales(self, info, query=None, **_kwargs):
return resolve_sales(info, query)
@permission_required('discount.manage_discounts')
@@ -41,7 +41,7 @@ class DiscountQueries(graphene.ObjectType):
return graphene.Node.get_node_from_global_id(info, id, Voucher)
@permission_required('discount.manage_discounts')
- def resolve_vouchers(self, info, query=None, **kwargs):
+ def resolve_vouchers(self, info, query=None, **_kwargs):
return resolve_vouchers(info, query)
diff --git a/saleor/graphql/discount/types.py b/saleor/graphql/discount/types.py
index a37ac159e9..07c7ad83ad 100644
--- a/saleor/graphql/discount/types.py
+++ b/saleor/graphql/discount/types.py
@@ -48,13 +48,13 @@ class Sale(CountableDjangoObjectType):
model = models.Sale
only_fields = ['end_date', 'id', 'name', 'start_date', 'type', 'value']
- def resolve_categories(self, info, **kwargs):
+ def resolve_categories(self, *_args, **_kwargs):
return self.categories.all()
- def resolve_collections(self, info, **kwargs):
+ def resolve_collections(self, info, **_kwargs):
return self.collections.visible_to_user(info.context.user)
- def resolve_products(self, info, **kwargs):
+ def resolve_products(self, info, **_kwargs):
return self.products.visible_to_user(info.context.user)
@@ -99,16 +99,16 @@ class Voucher(CountableDjangoObjectType):
interfaces = [relay.Node]
model = models.Voucher
- def resolve_categories(self, info, **kwargs):
+ def resolve_categories(self, *_args, **_kwargs):
return self.categories.all()
- def resolve_collections(self, info, **kwargs):
+ def resolve_collections(self, info, **_kwargs):
return self.collections.visible_to_user(info.context.user)
- def resolve_products(self, info, **kwargs):
+ def resolve_products(self, info, **_kwargs):
return self.products.visible_to_user(info.context.user)
- def resolve_countries(self, info, **kwargs):
+ def resolve_countries(self, *_args, **_kwargs):
return [
CountryDisplay(code=country.code, country=country.name)
for country in self.countries]
diff --git a/saleor/graphql/menu/resolvers.py b/saleor/graphql/menu/resolvers.py
index 77313c132b..e8a0bc51d7 100644
--- a/saleor/graphql/menu/resolvers.py
+++ b/saleor/graphql/menu/resolvers.py
@@ -9,13 +9,13 @@ MENU_SEARCH_FIELDS = ('name',)
MENU_ITEM_SEARCH_FIELDS = ('name',)
-def resolve_menu(info, id=None, name=None):
- assert id or name, 'No ID or name provided.'
+def resolve_menu(info, menu_id=None, name=None):
+ assert menu_id or name, 'No ID or name provided.'
if name is not None:
qs = models.Menu.objects.filter(name=name)
qs = gql_optimizer.query(qs, info)
return qs[0] if qs else None
- return graphene.Node.get_node_from_global_id(info, id, Menu)
+ return graphene.Node.get_node_from_global_id(info, menu_id, Menu)
def resolve_menus(info, query):
diff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.py
index 16376f6a91..e47b3f6067 100644
--- a/saleor/graphql/menu/types.py
+++ b/saleor/graphql/menu/types.py
@@ -28,8 +28,9 @@ class Menu(CountableDjangoObjectType):
prefetch_related=prefetch_menus)
class Meta:
- description = dedent("""Represents a single menu - an object that is used
- to help navigate through the store.""")
+ description = dedent(
+ """Represents a single menu - an object that is used
+ to help navigate through the store.""")
interfaces = [relay.Node]
only_fields = ['id', 'name']
model = models.Menu
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index 356ddd15f5..6caa4b2a0d 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -26,7 +26,7 @@ class FulfillmentLineInput(graphene.InputObjectType):
order_line_id = graphene.ID(
description='The ID of the order line.', name='orderLineId')
quantity = graphene.Int(
- description='The number of line item(s) to be fulfiled.')
+ description='The number of line item(s) to be fulfilled.')
class FulfillmentCreateInput(graphene.InputObjectType):
@@ -172,7 +172,7 @@ class FulfillmentUpdateTracking(BaseMutation):
order = fulfillment.order
order.events.create(
parameters={
- 'tracking_numner': tracking_number,
+ 'tracking_number': tracking_number,
'fulfillment': fulfillment.composed_id},
type=OrderEvents.TRACKING_UPDATED.value,
user=info.context.user)
@@ -197,7 +197,7 @@ class FulfillmentCancel(BaseMutation):
and optionally restocks items.""")
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user, _data):
return user.has_perm('order.manage_orders')
@classmethod
@@ -221,7 +221,7 @@ class FulfillmentCancel(BaseMutation):
parameters={'quantity': fulfillment.get_total_quantity()},
type=OrderEvents.FULFILLMENT_RESTOCKED_ITEMS.value,
user=info.context.user)
- else:
+ elif order:
order.events.create(
parameters={'composed_id': fulfillment.composed_id},
type=OrderEvents.FULFILLMENT_CANCELED.value,
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 5990375189..74024d4b6a 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -41,7 +41,7 @@ def clean_order_cancel(order):
raise ValidationError({'order': 'This order can\'t be canceled.'})
-def clean_order_capture(payment, amount):
+def clean_order_capture(payment):
if not payment:
raise ValidationError({
'payment': 'There\'s no payment associated with the order.'})
@@ -274,7 +274,7 @@ class OrderCapture(BaseMutation):
order = cls.get_node_or_error(
info, data.get('id'), only_type=Order)
payment = order.get_last_payment()
- clean_order_capture(payment, amount)
+ clean_order_capture(payment)
try:
gateway_capture(payment, amount)
diff --git a/saleor/graphql/order/resolvers.py b/saleor/graphql/order/resolvers.py
index 8f500ffbee..59a28d2125 100644
--- a/saleor/graphql/order/resolvers.py
+++ b/saleor/graphql/order/resolvers.py
@@ -54,7 +54,7 @@ def resolve_order(info, order_id):
return None
-def resolve_homepage_events(info):
+def resolve_homepage_events():
# Filter only selected events to be displayed on homepage.
types = [
OrderEvents.PLACED.value, OrderEvents.PLACED_FROM_DRAFT.value,
@@ -62,5 +62,5 @@ def resolve_homepage_events(info):
return models.OrderEvent.objects.filter(type__in=types)
-def resolve_order_by_token(info, token):
+def resolve_order_by_token(token):
return models.Order.objects.filter(token=token).first()
diff --git a/saleor/graphql/order/schema.py b/saleor/graphql/order/schema.py
index d8c80fe73f..54a3952ba3 100644
--- a/saleor/graphql/order/schema.py
+++ b/saleor/graphql/order/schema.py
@@ -58,8 +58,8 @@ class OrderQueries(graphene.ObjectType):
token=graphene.Argument(graphene.String, required=True))
@permission_required('order.manage_orders')
- def resolve_homepage_events(self, info, **_kwargs):
- return resolve_homepage_events(info)
+ def resolve_homepage_events(self, *_args, **_kwargs):
+ return resolve_homepage_events()
@login_required
def resolve_order(self, info, **data):
@@ -67,19 +67,19 @@ class OrderQueries(graphene.ObjectType):
@permission_required('order.manage_orders')
def resolve_orders(
- self, info, created=None, status=None, query=None, **kwargs):
+ self, info, created=None, status=None, query=None, **_kwargs):
return resolve_orders(info, created, status, query)
@permission_required('order.manage_orders')
- def resolve_draft_orders(self, info, created=None, query=None, **kwargs):
+ def resolve_draft_orders(self, info, created=None, query=None, **_kwargs):
return resolve_draft_orders(info, created, query)
@permission_required('order.manage_orders')
- def resolve_orders_total(self, info, period, **kwargs):
+ def resolve_orders_total(self, info, period, **_kwargs):
return resolve_orders_total(info, period)
- def resolve_order_by_token(self, info, token):
- return resolve_order_by_token(info, token)
+ def resolve_order_by_token(self, _info, token):
+ return resolve_order_by_token(token)
class OrderMutations(graphene.ObjectType):
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index e022cf0e3e..fe13ac73af 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -238,7 +238,7 @@ class Order(CountableDjangoObjectType):
return self.shipping_price
@gql_optimizer.resolver_hints(prefetch_related='payments__transactions')
- def resolve_actions(self, info):
+ def resolve_actions(self, _info):
actions = []
payment = self.get_last_payment()
if self.can_capture(payment):
@@ -321,7 +321,7 @@ class Order(CountableDjangoObjectType):
return self.user.email
return None
- def resolve_available_shipping_methods(self, info):
+ def resolve_available_shipping_methods(self, _info):
return applicable_shipping_methods(
self, self.get_subtotal().gross.amount)
diff --git a/saleor/graphql/page/resolvers.py b/saleor/graphql/page/resolvers.py
index 6865242b4a..b3300df781 100644
--- a/saleor/graphql/page/resolvers.py
+++ b/saleor/graphql/page/resolvers.py
@@ -7,8 +7,8 @@ from .types import Page
PAGE_SEARCH_FIELDS = ('content', 'slug', 'title')
-def resolve_page(info, id=None, slug=None):
- assert id or slug, 'No page ID or slug provided.'
+def resolve_page(info, page_id=None, slug=None):
+ assert page_id or slug, 'No page ID or slug provided.'
user = info.context.user
if slug is not None:
@@ -17,7 +17,7 @@ def resolve_page(info, id=None, slug=None):
except models.Page.DoesNotExist:
page = None
else:
- page = graphene.Node.get_node_from_global_id(info, id, Page)
+ page = graphene.Node.get_node_from_global_id(info, page_id, Page)
# Resolve to null if page is not published and user has no permission
# to manage pages.
is_available_to_user = (
diff --git a/saleor/graphql/page/types.py b/saleor/graphql/page/types.py
index fc8a046506..4c2e362333 100644
--- a/saleor/graphql/page/types.py
+++ b/saleor/graphql/page/types.py
@@ -28,8 +28,9 @@ class Page(CountableDjangoObjectType):
resolver=resolve_translation)
class Meta:
- description = dedent("""A static page that can be manually added by a shop
- operator through the dashboard.""")
+ description = dedent(
+ """A static page that can be manually added by a shop
+ operator through the dashboard.""")
only_fields = [
'content', 'content_json', 'created', 'id', 'is_published',
'publication_date', 'seo_description', 'seo_title', 'slug',
diff --git a/saleor/graphql/payment/types.py b/saleor/graphql/payment/types.py
index 84ca5dd256..e37f9fabef 100644
--- a/saleor/graphql/payment/types.py
+++ b/saleor/graphql/payment/types.py
@@ -23,7 +23,7 @@ class Transaction(CountableDjangoObjectType):
'id', 'created', 'payment', 'token', 'kind', 'is_success',
'error', 'gateway_response']
- def resolve_amount(self, info):
+ def resolve_amount(self, _info):
return self.get_amount()
@@ -78,7 +78,7 @@ class Payment(CountableDjangoObjectType):
'extra_data']
@gql_optimizer.resolver_hints(prefetch_related='transactions')
- def resolve_actions(self, info):
+ def resolve_actions(self, _info):
actions = []
if self.can_capture():
actions.append(OrderAction.CAPTURE)
@@ -88,13 +88,13 @@ class Payment(CountableDjangoObjectType):
actions.append(OrderAction.VOID)
return actions
- def resolve_total(self, info):
+ def resolve_total(self, _info):
return self.get_total()
- def resolve_captured_amount(self, info):
+ def resolve_captured_amount(self, _info):
return self.get_captured_amount()
- def resolve_billing_address(self, info):
+ def resolve_billing_address(self, _info):
return Address(
first_name=self.billing_first_name,
last_name=self.billing_last_name,
@@ -108,23 +108,23 @@ class Payment(CountableDjangoObjectType):
country_area=self.billing_country_area)
@gql_optimizer.resolver_hints(prefetch_related='transactions')
- def resolve_transactions(self, info):
+ def resolve_transactions(self, _info):
return self.transactions.all()
- def resolve_available_refund_amount(self, info):
+ def resolve_available_refund_amount(self, _info):
# FIXME TESTME
if not self.can_refund():
return None
return self.get_captured_amount()
@gql_optimizer.resolver_hints(prefetch_related='transactions')
- def resolve_available_capture_amount(self, info):
+ def resolve_available_capture_amount(self, _info):
# FIXME TESTME
if not self.can_capture():
return None
return self.get_charge_amount()
- def resolve_credit_card(self, info):
+ def resolve_credit_card(self, _info):
data = {
'first_digits': self.cc_first_digits,
'last_digits': self.cc_last_digits,
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 4277090090..93be40558c 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -452,9 +452,10 @@ class ProductVariantInput(graphene.InputObjectType):
quantity = graphene.Int(
description='The total quantity of this variant available for sale.')
track_inventory = graphene.Boolean(
- description=dedent("""Determines if the inventory of this variant should
- be tracked. If false, the quantity won't change when customers
- buy this item."""))
+ description=dedent(
+ """Determines if the inventory of this variant should
+ be tracked. If false, the quantity won't change when customers
+ buy this item."""))
weight = WeightScalar(
description='Weight of the Product Variant.', required=False)
diff --git a/saleor/graphql/product/resolvers.py b/saleor/graphql/product/resolvers.py
index 1dbcf35911..4cf0c2d5a4 100644
--- a/saleor/graphql/product/resolvers.py
+++ b/saleor/graphql/product/resolvers.py
@@ -74,7 +74,7 @@ def resolve_collections(info, query):
return gql_optimizer.query(qs, info)
-def resolve_digital_contents(info, query):
+def resolve_digital_contents(info):
qs = models.DigitalContent.objects.all()
return gql_optimizer.query(qs, info)
@@ -82,7 +82,7 @@ def resolve_digital_contents(info, query):
def resolve_products(
info, attributes=None, categories=None, collections=None,
price_lte=None, price_gte=None, sort_by=None, stock_availability=None,
- query=None, **kwargs):
+ query=None, **_kwargs):
user = info.context.user
qs = models.Product.objects.visible_to_user(user)
@@ -135,7 +135,7 @@ def resolve_product_variants(info, ids=None):
return gql_optimizer.query(qs, info)
-def resolve_report_product_sales(info, period):
+def resolve_report_product_sales(period):
qs = models.ProductVariant.objects.prefetch_related(
'product', 'product__images', 'order_lines__order').all()
diff --git a/saleor/graphql/product/schema.py b/saleor/graphql/product/schema.py
index 1c81a98c5c..06f6546796 100644
--- a/saleor/graphql/product/schema.py
+++ b/saleor/graphql/product/schema.py
@@ -117,10 +117,10 @@ class ProductQueries(graphene.ObjectType):
def resolve_attributes(
self, info, in_category=None, in_collection=None, query=None,
- **kwargs):
+ **_kwargs):
return resolve_attributes(info, in_category, in_collection, query)
- def resolve_categories(self, info, level=None, query=None, **kwargs):
+ def resolve_categories(self, info, level=None, query=None, **_kwargs):
return resolve_categories(info, level=level, query=query)
def resolve_category(self, info, id):
@@ -129,7 +129,7 @@ class ProductQueries(graphene.ObjectType):
def resolve_collection(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, Collection)
- def resolve_collections(self, info, query=None, **kwargs):
+ def resolve_collections(self, info, query=None, **_kwargs):
return resolve_collections(info, query)
@permission_required('product.manage_products')
@@ -137,8 +137,8 @@ class ProductQueries(graphene.ObjectType):
return graphene.Node.get_node_from_global_id(info, id, DigitalContent)
@permission_required('product.manage_products')
- def resolve_digital_contents(self, info, query=None, **kwargs):
- return resolve_digital_contents(info, query)
+ def resolve_digital_contents(self, info, **_kwargs):
+ return resolve_digital_contents(info)
def resolve_product(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, Product)
@@ -149,18 +149,18 @@ class ProductQueries(graphene.ObjectType):
def resolve_product_type(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, ProductType)
- def resolve_product_types(self, info, **kwargs):
+ def resolve_product_types(self, info, **_kwargs):
return resolve_product_types(info)
def resolve_product_variant(self, info, id):
return graphene.Node.get_node_from_global_id(info, id, ProductVariant)
- def resolve_product_variants(self, info, ids=None, **kwargs):
+ def resolve_product_variants(self, info, ids=None, **_kwargs):
return resolve_product_variants(info, ids)
@permission_required(['order.manage_orders', 'product.manage_products'])
- def resolve_report_product_sales(self, info, period, **kwargs):
- return resolve_report_product_sales(info, period)
+ def resolve_report_product_sales(self, *_args, period, **_kwargs):
+ return resolve_report_product_sales(period)
class ProductMutations(graphene.ObjectType):
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index 84f7f43505..82a4f1306e 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -89,7 +89,7 @@ class AttributeValue(CountableDjangoObjectType):
interfaces = [relay.Node]
model = models.AttributeValue
- def resolve_type(self, info):
+ def resolve_type(self, *_args):
return resolve_attribute_value_type(self.value)
@@ -112,13 +112,14 @@ class Attribute(CountableDjangoObjectType):
resolver=resolve_translation)
class Meta:
- description = dedent("""Custom attribute of a product. Attributes can be
- assigned to products and variants at the product type level.""")
+ description = dedent("""
+ Custom attribute of a product. Attributes can be
+ assigned to products and variants at the product type level.""")
only_fields = ['id', 'product_type', 'product_variant_type']
interfaces = [relay.Node]
model = models.Attribute
- def resolve_values(self, info):
+ def resolve_values(self, *_args):
return self.values.all()
@@ -147,7 +148,7 @@ class DigitalContentUrl(CountableDjangoObjectType):
only_fields = ['content', 'created', 'download_num', 'token', 'url']
interfaces = (relay.Node,)
- def resolve_url(self, info):
+ def resolve_url(self, *_args):
return self.get_absolute_url()
@@ -166,7 +167,7 @@ class DigitalContent(CountableDjangoObjectType):
'use_default_settings']
interfaces = (relay.Node,)
- def resolve_urls(self, info, **kwargs):
+ def resolve_urls(self, info, **_kwargs):
qs = self.urls.all()
return gql_optimizer.query(qs, info)
@@ -185,9 +186,10 @@ class ProductVariant(CountableDjangoObjectType):
required=True, description='Quantity of a product available for sale.')
price_override = graphene.Field(
Money,
- description=dedent("""Override the base price of a product if necessary.
- A value of `null` indicates that the default product
- price is used."""))
+ description=dedent(
+ """Override the base price of a product if necessary.
+ A value of `null` indicates that the default product
+ price is used."""))
price = graphene.Field(Money, description='Price of the product variant.')
attributes = graphene.List(
graphene.NonNull(SelectedAttribute), required=True,
@@ -231,51 +233,51 @@ class ProductVariant(CountableDjangoObjectType):
model = models.ProductVariant
@permission_required('product.manage_products')
- def resolve_digital_content(self, info):
+ def resolve_digital_content(self, *_args):
return getattr(self, 'digital_content', None)
- def resolve_stock_quantity(self, info):
+ def resolve_stock_quantity(self, *_args):
return self.quantity_available
@gql_optimizer.resolver_hints(
prefetch_related='product__product_type__variant_attributes__values')
- def resolve_attributes(self, info):
+ def resolve_attributes(self, *_args):
attributes_qs = self.product.product_type.variant_attributes.all()
return resolve_attribute_list(self.attributes, attributes_qs)
@permission_required('product.manage_products')
- def resolve_margin(self, info):
+ def resolve_margin(self, *_args):
return get_margin_for_variant(self)
- def resolve_price(self, info):
+ def resolve_price(self, *_args):
return (
self.price_override
if self.price_override is not None else self.product.price)
@permission_required('product.manage_products')
- def resolve_price_override(self, info):
+ def resolve_price_override(self, *_args):
return self.price_override
@permission_required('product.manage_products')
- def resolve_quantity(self, info):
+ def resolve_quantity(self, *_args):
return self.quantity
@permission_required(['order.manage_orders', 'product.manage_products'])
- def resolve_quantity_ordered(self, info):
+ def resolve_quantity_ordered(self, *_args):
# This field is added through annotation when using the
# `resolve_report_product_sales` resolver.
return getattr(self, 'quantity_ordered', None)
@permission_required(['order.manage_orders', 'product.manage_products'])
- def resolve_quantity_allocated(self, info):
+ def resolve_quantity_allocated(self, *_args):
return self.quantity_allocated
@permission_required(['order.manage_orders', 'product.manage_products'])
- def resolve_revenue(self, info, period):
+ def resolve_revenue(self, *_args, period):
start_date = reporting_period_to_date(period)
return calculate_revenue_for_variant(self, start_date)
- def resolve_images(self, info):
+ def resolve_images(self, *_args):
return self.images.all()
@classmethod
@@ -315,8 +317,9 @@ class Product(CountableDjangoObjectType):
Image, description='The main thumbnail for a product.',
size=graphene.Argument(graphene.Int, description='Size of thumbnail'))
availability = graphene.Field(
- ProductAvailability, description=dedent("""Informs about product's availability in the
- storefront, current price and discounts."""))
+ ProductAvailability, description=dedent(
+ """Informs about product's availability in the
+ storefront, current price and discounts."""))
price = graphene.Field(
Money,
description=dedent("""The product's base price (without any discounts
@@ -387,7 +390,7 @@ class Product(CountableDjangoObjectType):
alt = image.alt if image else None
return Image(alt=alt, url=url)
- def resolve_url(self, info):
+ def resolve_url(self, *_args):
return self.get_absolute_url()
@gql_optimizer.resolver_hints(
@@ -401,17 +404,17 @@ class Product(CountableDjangoObjectType):
@gql_optimizer.resolver_hints(
prefetch_related='product_type__product_attributes__values')
- def resolve_attributes(self, info):
+ def resolve_attributes(self, *_args):
attributes_qs = self.product_type.product_attributes.all()
return resolve_attribute_list(self.attributes, attributes_qs)
@permission_required('product.manage_products')
- def resolve_purchase_cost(self, info):
+ def resolve_purchase_cost(self, *_args):
purchase_cost, _ = get_product_costs_data(self)
return purchase_cost
@permission_required('product.manage_products')
- def resolve_margin(self, info):
+ def resolve_margin(self, *_args):
_, margin = get_product_costs_data(self)
return Margin(margin[0], margin[1])
@@ -423,16 +426,16 @@ class Product(CountableDjangoObjectType):
raise GraphQLError('Product image not found.')
@gql_optimizer.resolver_hints(model_field='images')
- def resolve_images(self, info, **kwargs):
+ def resolve_images(self, *_args, **_kwargs):
return self.images.all()
- def resolve_variants(self, info, **kwargs):
+ def resolve_variants(self, *_args, **_kwargs):
return self.variants.all()
- def resolve_collections(self, info):
+ def resolve_collections(self, *_args):
return self.collections.all()
- def resolve_available_on(self, info):
+ def resolve_available_on(self, *_args):
return self.publication_date
@classmethod
@@ -447,7 +450,7 @@ class Product(CountableDjangoObjectType):
return None
-def prefetch_products(info, *args, **kwargs):
+def prefetch_products(info, *_args, **_kwargs):
"""Prefetch products visible to the current user.
Can be used with models that have the `products` relationship. Queryset of
@@ -482,14 +485,14 @@ class ProductType(CountableDjangoObjectType):
'weight']
@gql_optimizer.resolver_hints(prefetch_related='product_attributes')
- def resolve_product_attributes(self, info, **kwargs):
+ def resolve_product_attributes(self, *_args, **_kwargs):
return self.product_attributes.all()
@gql_optimizer.resolver_hints(prefetch_related='variant_attributes')
- def resolve_variant_attributes(self, info, **kwargs):
+ def resolve_variant_attributes(self, *_args, **_kwargs):
return self.variant_attributes.all()
- def resolve_products(self, info, **kwargs):
+ def resolve_products(self, info, **_kwargs):
if hasattr(self, 'prefetched_products'):
return self.prefetched_products
qs = self.products.visible_to_user(info.context.user)
@@ -525,7 +528,7 @@ class Collection(CountableDjangoObjectType):
interfaces = [relay.Node]
model = models.Collection
- def resolve_background_image(self, info, size=None, **kwargs):
+ def resolve_background_image(self, info, size=None, **_kwargs):
if self.background_image:
return Image.get_adjusted(
image=self.background_image,
@@ -535,13 +538,13 @@ class Collection(CountableDjangoObjectType):
info=info,
)
- def resolve_products(self, info, **kwargs):
+ def resolve_products(self, info, **_kwargs):
if hasattr(self, 'prefetched_products'):
return self.prefetched_products
qs = self.products.visible_to_user(info.context.user)
return gql_optimizer.query(qs, info)
- def resolve_published_date(self, info):
+ def resolve_published_date(self, *_args):
return self.publication_date
@classmethod
@@ -591,11 +594,11 @@ class Category(CountableDjangoObjectType):
interfaces = [relay.Node]
model = models.Category
- def resolve_ancestors(self, info, **kwargs):
+ def resolve_ancestors(self, info, **_kwargs):
qs = self.get_ancestors()
return gql_optimizer.query(qs, info)
- def resolve_background_image(self, info, size=None, **kwargs):
+ def resolve_background_image(self, info, size=None, **_kwargs):
if self.background_image:
return Image.get_adjusted(
image=self.background_image,
@@ -605,14 +608,14 @@ class Category(CountableDjangoObjectType):
info=info,
)
- def resolve_children(self, info, **kwargs):
+ def resolve_children(self, info, **_kwargs):
qs = self.children.all()
return gql_optimizer.query(qs, info)
- def resolve_url(self, info):
+ def resolve_url(self, _info):
return self.get_absolute_url()
- def resolve_products(self, info, **kwargs):
+ def resolve_products(self, info, **_kwargs):
# If the category has no children, we use the prefetched data.
children = self.children.all()
if not children and hasattr(self, 'prefetched_products'):
diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.py
index 10795d7630..28981a33a8 100644
--- a/saleor/graphql/shipping/mutations.py
+++ b/saleor/graphql/shipping/mutations.py
@@ -114,9 +114,9 @@ class ShippingPriceMixin:
@classmethod
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:
+ cleaned_type = cleaned_input.get('type')
+ if cleaned_type:
+ if cleaned_type == ShippingMethodTypeEnum.PRICE.value:
min_price = cleaned_input.get('minimum_order_price')
max_price = cleaned_input.get('maximum_order_price')
if (min_price is not None and max_price is not None
diff --git a/saleor/graphql/shipping/schema.py b/saleor/graphql/shipping/schema.py
index 8c91b119b4..7f03fbffc7 100644
--- a/saleor/graphql/shipping/schema.py
+++ b/saleor/graphql/shipping/schema.py
@@ -23,7 +23,7 @@ class ShippingQueries(graphene.ObjectType):
return graphene.Node.get_node_from_global_id(info, id, ShippingZone)
@permission_required('shipping.manage_shipping')
- def resolve_shipping_zones(self, info, **kwargs):
+ def resolve_shipping_zones(self, info, **_kwargs):
return resolve_shipping_zones(info)
diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.py
index 2e287b754d..3619684c73 100644
--- a/saleor/graphql/shipping/types.py
+++ b/saleor/graphql/shipping/types.py
@@ -61,13 +61,13 @@ class ShippingZone(CountableDjangoObjectType):
interfaces = [relay.Node]
only_fields = ['default', 'id', 'name']
- def resolve_price_range(self, info):
+ def resolve_price_range(self, *_args):
return self.price_range
- def resolve_countries(self, info):
+ def resolve_countries(self, *_args):
return [
CountryDisplay(code=country.code, country=country.name)
for country in self.countries]
- def resolve_shipping_methods(self, info):
+ def resolve_shipping_methods(self, *_args):
return self.shipping_methods.all()
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index 2c34704f84..a02516af15 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -179,7 +179,7 @@ class AuthorizationKeyAdd(BaseMutation):
class AuthorizationKeyDelete(BaseMutation):
authorization_key = graphene.Field(
- AuthorizationKey, description='Auhtorization key that was deleted.')
+ AuthorizationKey, description='Authorization key that was deleted.')
shop = graphene.Field(Shop, description='Updated Shop')
class Arguments:
diff --git a/saleor/graphql/shop/schema.py b/saleor/graphql/shop/schema.py
index 0b160a566f..4e55425a3a 100644
--- a/saleor/graphql/shop/schema.py
+++ b/saleor/graphql/shop/schema.py
@@ -10,7 +10,7 @@ from .types import Shop
class ShopQueries(graphene.ObjectType):
shop = graphene.Field(Shop, description='Represents a shop resources.')
- def resolve_shop(self, info):
+ def resolve_shop(self, _info):
return Shop()
diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.py
index 7bc8abe52d..46a2283312 100644
--- a/saleor/graphql/shop/types.py
+++ b/saleor/graphql/shop/types.py
@@ -68,9 +68,10 @@ class Shop(graphene.ObjectType):
description='Customer\'s geolocalization data.')
authorization_keys = graphene.List(
AuthorizationKey,
- description=dedent('''List of configured authorization keys. Authorization
- keys are used to enable thrid party OAuth authorization (currently
- Facebook or Google).'''),
+ description=dedent(
+ '''List of configured authorization keys. Authorization
+ keys are used to enable third party OAuth authorization
+ (currently Facebook or Google).'''),
required=True)
countries = graphene.List(
CountryDisplay, description='List of countries available in the shop.',
@@ -175,7 +176,8 @@ class Shop(graphene.ObjectType):
def resolve_languages(self, _info):
return [
LanguageDisplay(
- code=LanguageCodeEnum[str_to_enum(language[0])], language=language[1])
+ code=LanguageCodeEnum[str_to_enum(language[0])],
+ language=language[1])
for language in settings.LANGUAGES]
def resolve_name(self, info):
@@ -216,7 +218,7 @@ class Shop(graphene.ObjectType):
def resolve_default_weight_unit(self, info):
return info.context.site.settings.default_weight_unit
- def resolve_default_country(self, info):
+ def resolve_default_country(self, _info):
default_country_code = settings.DEFAULT_COUNTRY
default_country_name = countries.countries.get(default_country_code)
if default_country_name:
diff --git a/saleor/graphql/translations/resolvers.py b/saleor/graphql/translations/resolvers.py
index ad7025f99b..dccd51ebb0 100644
--- a/saleor/graphql/translations/resolvers.py
+++ b/saleor/graphql/translations/resolvers.py
@@ -4,7 +4,7 @@ from ...product import models as product_models
from ...shipping import models as shipping_models
-def resolve_translation(instance, info, language_code):
+def resolve_translation(instance, _info, language_code):
"""Gets translation object from instance based on language code."""
return instance.translations.filter(language_code=language_code).first()
diff --git a/saleor/graphql/translations/schema.py b/saleor/graphql/translations/schema.py
index 8cdbd99225..fb141b2660 100644
--- a/saleor/graphql/translations/schema.py
+++ b/saleor/graphql/translations/schema.py
@@ -58,7 +58,7 @@ class TranslationQueries(graphene.ObjectType):
TranslatableKinds,
required=True, description='Kind of objects to retrieve.'))
- def resolve_translations(self, info, kind, **kwargs):
+ def resolve_translations(self, info, kind, **_kwargs):
if kind == TranslatableKinds.PRODUCT:
return resolve_products(info)
elif kind == TranslatableKinds.COLLECTION:
diff --git a/saleor/graphql/translations/types.py b/saleor/graphql/translations/types.py
index 2aa58daa15..cfb531debf 100644
--- a/saleor/graphql/translations/types.py
+++ b/saleor/graphql/translations/types.py
@@ -20,7 +20,7 @@ class BaseTranslationType(CountableDjangoObjectType):
class Meta:
abstract = True
- def resolve_language(self, info):
+ def resolve_language(self, *_args):
try:
language = next(
language[1] for language in settings.LANGUAGES
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 90f030474d..2e1945b066 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -55,7 +55,7 @@ class GraphQLView(View):
if request.method == 'OPTIONS':
response = self.options(request, *args, **kwargs)
elif request.method == 'POST':
- response = self.handle_query(request, *args, **kwargs)
+ response = self.handle_query(request)
else:
return HttpResponseNotAllowed(
['GET', 'OPTIONS', 'POST'])
@@ -67,7 +67,7 @@ class GraphQLView(View):
'Origin, Content-Type, Accept, Authorization')
return response
- def handle_query(self, request: HttpRequest, *args, **kwargs):
+ def handle_query(self, request: HttpRequest):
try:
data = self.parse_body(request)
except ValueError:
@@ -102,7 +102,7 @@ class GraphQLView(View):
result = None
return result, status_code
- def get_root_value(self, request: HttpRequest):
+ def get_root_value(self):
return self.root_value
def parse_query(self, query: str) -> (GraphQLDocument, ExecutionResult):
@@ -138,7 +138,7 @@ class GraphQLView(View):
extra_options['executor'] = self.executor
try:
return document.execute(
- root=self.get_root_value(request),
+ root=self.get_root_value(),
variables=variables,
operation_name=operation_name,
context=request,
diff --git a/tests/api/test_order.py b/tests/api/test_order.py
index d8db70d373..689e9c8dd2 100644
--- a/tests/api/test_order.py
+++ b/tests/api/test_order.py
@@ -1230,9 +1230,8 @@ def test_clean_order_refund_payment():
def test_clean_order_capture():
- amount = Mock(spec='string')
with pytest.raises(ValidationError) as e:
- clean_order_capture(None, amount)
+ clean_order_capture(None)
msg = 'There\'s no payment associated with the order.'
assert e.value.error_dict['payment'][0].message == msg