Skip to content

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

Use ruff instead of black for code formatting (#14456)

Patryk Zawadzki2a827e719fee
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6b30f9a6a0..5390d82346 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,11 +1,5 @@
exclude: ^.semgrep/
repos:
- - repo: https://github.com/ambv/black
- rev: 23.10.0
- hooks:
- - id: black
- language_version: python3.9
-
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
@@ -17,9 +11,10 @@ repos:
exclude_types: [svg]
- repo: https://github.com/charliermarsh/ruff-pre-commit
- rev: v0.1.1
+ rev: v0.1.2
hooks:
- id: ruff
+ - id: ruff-format
- repo: https://github.com/pycqa/isort
rev: 5.12.0
diff --git a/.vscode/settings.json b/.vscode/settings.json
index caff6eca01..cd6000a603 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,9 +1,7 @@
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
- "python.formatting.provider": "black",
"python.languageServer": "Pylance",
- "python.linting.mypyEnabled": true,
"python.analysis.typeCheckingMode": "basic",
"cSpell.words": [
"dataloaders",
@@ -11,5 +9,9 @@
"preorders",
"undiscounted"
],
- "python.linting.enabled": true
+ "[python]": {
+ "editor.defaultFormatter": "charliermarsh.ruff",
+ "editor.formatOnSave": true,
+ "editor.formatOnType": true
+ }
}
diff --git a/saleor/account/management/commands/createsuperuser.py b/saleor/account/management/commands/createsuperuser.py
index 170e467d06..a9dea54b3e 100644
--- a/saleor/account/management/commands/createsuperuser.py
+++ b/saleor/account/management/commands/createsuperuser.py
@@ -241,9 +241,7 @@ class Command(BaseCommand):
"to create one manually."
)
- def get_input_data(
- self, field, message, default=None
- ): # noqa: D205, D212, D400, D415
+ def get_input_data(self, field, message, default=None): # noqa: D205, D212, D400, D415
"""
Override this method if you want to customize data inputs or
validation exceptions.
diff --git a/saleor/app/installation_utils.py b/saleor/app/installation_utils.py
index 2c945c4a9f..cd1e3089a5 100644
--- a/saleor/app/installation_utils.py
+++ b/saleor/app/installation_utils.py
@@ -78,7 +78,7 @@ def fetch_icon_image(
url: str,
*,
max_file_size=MAX_ICON_FILE_SIZE,
- timeout=settings.COMMON_REQUESTS_TIMEOUT
+ timeout=settings.COMMON_REQUESTS_TIMEOUT,
) -> File:
filename = get_filename_from_url(url)
size_error_msg = f"File too big. Maximal icon image file size is {max_file_size}."
@@ -182,7 +182,7 @@ def fetch_brand_data_async(
manifest_data: dict,
*,
app_installation: Optional[AppInstallation] = None,
- app: Optional[App] = None
+ app: Optional[App] = None,
):
if brand_data := manifest_data.get("brand"):
app_id = app.pk if app else None
@@ -261,9 +261,7 @@ def install_app(app_installation: AppInstallation, activate: bool = False):
)
WebhookEvent.objects.bulk_create(webhook_events)
- _, token = app.tokens.create(
- name="Default token"
- ) # type: ignore[call-arg] # calling create on a related manager # noqa: E501
+ _, token = app.tokens.create(name="Default token") # type: ignore[call-arg] # calling create on a related manager # noqa: E501
try:
send_app_token(target_url=manifest_data.get("tokenTargetUrl"), token=token)
diff --git a/saleor/app/tests/test_installation_utils.py b/saleor/app/tests/test_installation_utils.py
index 20459170a4..27c9f12187 100644
--- a/saleor/app/tests/test_installation_utils.py
+++ b/saleor/app/tests/test_installation_utils.py
@@ -546,9 +546,7 @@ def test_install_app_webhook_incorrect_query(
app_manifest, app_manifest_webhook, app_installation, monkeypatch
):
# given
- app_manifest_webhook[
- "query"
- ] = """
+ app_manifest_webhook["query"] = """
no {
that's {
not {
diff --git a/saleor/auth/migrations/0011_update_proxy_permissions.py b/saleor/auth/migrations/0011_update_proxy_permissions.py
index 17cd5b8b03..1bb54df631 100644
--- a/saleor/auth/migrations/0011_update_proxy_permissions.py
+++ b/saleor/auth/migrations/0011_update_proxy_permissions.py
@@ -14,9 +14,7 @@ WARNING = """
"""
-def update_proxy_model_permissions(
- apps, schema_editor, reverse=False
-): # noqa: D205, D212, D400, D415
+def update_proxy_model_permissions(apps, schema_editor, reverse=False): # noqa: D205, D212, D400, D415
"""
Update the content_type of proxy model permissions to use the ContentType
of the proxy model.
diff --git a/saleor/checkout/fetch.py b/saleor/checkout/fetch.py
index c7020daa36..f7c0d785b4 100644
--- a/saleor/checkout/fetch.py
+++ b/saleor/checkout/fetch.py
@@ -638,9 +638,7 @@ def update_delivery_method_lists_for_checkout_info(
initialize_shipping_method_active_status(all_methods, excluded_methods)
return all_methods
- checkout_info.all_shipping_methods = lazy_no_retry(
- _resolve_all_shipping_methods
- ) # type: ignore[assignment] # using lazy object breaks protocol
+ checkout_info.all_shipping_methods = lazy_no_retry(_resolve_all_shipping_methods) # type: ignore[assignment] # using lazy object breaks protocol
checkout_info.valid_pick_up_points = lazy_no_retry(
lambda: (get_valid_collection_points_for_checkout_info(lines, checkout_info))
) # type: ignore[assignment] # using lazy object breaks protocol
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 3efe82c558..23e454a61b 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -198,11 +198,7 @@ class Checkout(models.Model):
"""Return the total balance of the gift cards assigned to the checkout."""
balance = self.gift_cards.active( # type: ignore[attr-defined] # problem with django-stubs detecting the correct manager # noqa: E501
date=date.today()
- ).aggregate(
- models.Sum("current_balance_amount")
- )[
- "current_balance_amount__sum"
- ]
+ ).aggregate(models.Sum("current_balance_amount"))["current_balance_amount__sum"]
if balance is None:
return zero_money(currency=self.currency)
return Money(balance, self.currency)
diff --git a/saleor/checkout/problems.py b/saleor/checkout/problems.py
index 972019a95e..fd5acea256 100644
--- a/saleor/checkout/problems.py
+++ b/saleor/checkout/problems.py
@@ -183,7 +183,7 @@ def get_checkout_lines_problems(
def get_checkout_problems(
checkout_lines_problem: dict[
CHECKOUT_LINE_PK_TYPE, list[CHECKOUT_LINE_PROBLEM_TYPE]
- ]
+ ],
):
"""Return a list of all problems with the checkout.
diff --git a/saleor/csv/events.py b/saleor/csv/events.py
index 6da97166f8..f866fd7557 100644
--- a/saleor/csv/events.py
+++ b/saleor/csv/events.py
@@ -13,7 +13,7 @@ def export_started_event(
*,
export_file: "ExportFile",
user: Optional["User"] = None,
- app: Optional["App"] = None
+ app: Optional["App"] = None,
) -> None:
ExportEvent.objects.create(
export_file=export_file, user=user, app=app, type=ExportEvents.EXPORT_PENDING
@@ -24,7 +24,7 @@ def export_success_event(
*,
export_file: "ExportFile",
user: Optional["User"] = None,
- app: Optional["App"] = None
+ app: Optional["App"] = None,
) -> None:
ExportEvent.objects.create(
export_file=export_file, user=user, app=app, type=ExportEvents.EXPORT_SUCCESS
@@ -37,7 +37,7 @@ def export_failed_event(
user: Optional["User"] = None,
app: Optional["App"] = None,
message: str,
- error_type: str
+ error_type: str,
) -> None:
ExportEvent.objects.create(
export_file=export_file,
@@ -52,7 +52,7 @@ def export_deleted_event(
*,
export_file: "ExportFile",
user: Optional["User"] = None,
- app: Optional["App"] = None
+ app: Optional["App"] = None,
) -> None:
ExportEvent.objects.create(
export_file=export_file, user=user, app=app, type=ExportEvents.EXPORT_DELETED
diff --git a/saleor/demo/views.py b/saleor/demo/views.py
index 25f98b8105..f5e9eaecb9 100644
--- a/saleor/demo/views.py
+++ b/saleor/demo/views.py
@@ -22,9 +22,7 @@ EXAMPLE_QUERY = """# Welcome to Saleor GraphQL API!
}
}
}
-""" % {
- "channel_slug": settings.DEFAULT_CHANNEL_SLUG
-}
+""" % {"channel_slug": settings.DEFAULT_CHANNEL_SLUG}
class DemoGraphQLView(GraphQLView):
diff --git a/saleor/discount/migrations/0051_detach_sale_from_permission.py b/saleor/discount/migrations/0051_detach_sale_from_permission.py
index ff564b4bb9..937c8b65b1 100644
--- a/saleor/discount/migrations/0051_detach_sale_from_permission.py
+++ b/saleor/discount/migrations/0051_detach_sale_from_permission.py
@@ -17,7 +17,7 @@ def create_permissions(
interactive=True,
using=DEFAULT_DB_ALIAS,
apps=global_apps,
- **kwargs
+ **kwargs,
):
create_contenttypes(
app_config,
diff --git a/saleor/giftcard/notifications.py b/saleor/giftcard/notifications.py
index 305f950eb9..341e10ef93 100644
--- a/saleor/giftcard/notifications.py
+++ b/saleor/giftcard/notifications.py
@@ -19,7 +19,7 @@ def send_gift_card_notification(
manager,
channel_slug,
*,
- resending
+ resending,
):
"""Trigger sending a gift card notification for the given recipient."""
payload = {
diff --git a/saleor/graphql/account/i18n.py b/saleor/graphql/account/i18n.py
index cf41684c18..1b37317cba 100644
--- a/saleor/graphql/account/i18n.py
+++ b/saleor/graphql/account/i18n.py
@@ -109,7 +109,7 @@ class I18nMixin:
info=None,
format_check=True,
required_check=True,
- enable_normalization=True
+ enable_normalization=True,
):
if address_data.get("country") is None:
params = {"address_type": address_type} if address_type else {}
diff --git a/saleor/graphql/account/mutations/account/request_email_change.py b/saleor/graphql/account/mutations/account/request_email_change.py
index 6a9efe71d4..a905a597fa 100644
--- a/saleor/graphql/account/mutations/account/request_email_change.py
+++ b/saleor/graphql/account/mutations/account/request_email_change.py
@@ -68,7 +68,7 @@ class RequestEmailChange(BaseMutation):
channel=None,
new_email,
password,
- redirect_url
+ redirect_url,
):
user = info.context.user
user = cast(models.User, user)
diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.py
index 43e527496f..05b52ad575 100644
--- a/saleor/graphql/account/mutations/base.py
+++ b/saleor/graphql/account/mutations/base.py
@@ -428,7 +428,7 @@ class StaffDeleteMixin(UserDeleteMixin):
context: SaleorContext,
permissions=None,
require_all_permissions=False,
- **data
+ **data,
):
if get_app_promise(context).get():
raise PermissionDenied(
diff --git a/saleor/graphql/attribute/utils.py b/saleor/graphql/attribute/utils.py
index f86663dd7c..06922614a8 100644
--- a/saleor/graphql/attribute/utils.py
+++ b/saleor/graphql/attribute/utils.py
@@ -355,7 +355,7 @@ class AttributeAssignmentMixin:
attribute_qs: "QuerySet",
*,
creation: bool,
- is_page_attributes: bool
+ is_page_attributes: bool,
):
"""Check the cleaned attribute input.
diff --git a/saleor/graphql/checkout/mutations/checkout_email_update.py b/saleor/graphql/checkout/mutations/checkout_email_update.py
index 18d2fdf568..778d0887fc 100644
--- a/saleor/graphql/checkout/mutations/checkout_email_update.py
+++ b/saleor/graphql/checkout/mutations/checkout_email_update.py
@@ -69,7 +69,7 @@ class CheckoutEmailUpdate(BaseMutation):
checkout_id=None,
email,
id=None,
- token=None
+ token=None,
):
cls.clean_email(email)
diff --git a/saleor/graphql/checkout/mutations/checkout_language_code_update.py b/saleor/graphql/checkout/mutations/checkout_language_code_update.py
index 2da8f5d51c..44ebd9e264 100644
--- a/saleor/graphql/checkout/mutations/checkout_language_code_update.py
+++ b/saleor/graphql/checkout/mutations/checkout_language_code_update.py
@@ -59,7 +59,7 @@ class CheckoutLanguageCodeUpdate(BaseMutation):
checkout_id=None,
id=None,
language_code,
- token=None
+ token=None,
):
checkout = get_checkout(cls, info, checkout_id=checkout_id, token=token, id=id)
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_create.py b/saleor/graphql/checkout/tests/mutations/test_checkout_create.py
index 2e7e5626b3..62e8d77b71 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_create.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_create.py
@@ -2123,9 +2123,6 @@ def test_checkout_create_with_skip_value_check_saves_address(
assert getattr(created_checkout, address_db_field_name).country.code == country_code
-[("shippingAddress", "shipping_address"), ("billingAddress", "billing_address")],
-
-
@pytest.mark.parametrize(
"address_data, address_input_name, address_db_field_name",
[
diff --git a/saleor/graphql/core/filters.py b/saleor/graphql/core/filters.py
index be5abf3839..8192b2d3c5 100644
--- a/saleor/graphql/core/filters.py
+++ b/saleor/graphql/core/filters.py
@@ -202,12 +202,13 @@ class WhereFilterSet(django_filters.FilterSet):
if name not in self.form.data:
continue
queryset = self.filters[name].filter(queryset, value)
- assert isinstance(
- queryset, models.QuerySet
- ), "Expected '%s.%s' to return a QuerySet, but got a %s instead." % (
- type(self).__name__,
- name,
- type(queryset).__name__,
+ assert isinstance(queryset, models.QuerySet), (
+ "Expected '%s.%s' to return a QuerySet, but got a %s instead."
+ % (
+ type(self).__name__,
+ name,
+ type(queryset).__name__,
+ )
)
return queryset
diff --git a/saleor/graphql/core/validators/query_cost.py b/saleor/graphql/core/validators/query_cost.py
index 5b6f55610f..edba221f9e 100644
--- a/saleor/graphql/core/validators/query_cost.py
+++ b/saleor/graphql/core/validators/query_cost.py
@@ -127,9 +127,7 @@ class CostValidator(ValidationRule):
total += node_cost
return total
- def enter_operation_definition(
- self, node, key, parent, path, ancestors
- ): # pylint: disable=unused-argument
+ def enter_operation_definition(self, node, key, parent, path, ancestors): # pylint: disable=unused-argument
if self.cost_map:
try:
validate_cost_map(self.cost_map, self.context.get_schema())
@@ -150,9 +148,7 @@ class CostValidator(ValidationRule):
node, self.context.get_schema().get_subscription_type()
)
- def leave_operation_definition(
- self, node, key, parent, path, ancestors
- ): # pylint: disable=unused-argument
+ def leave_operation_definition(self, node, key, parent, path, ancestors): # pylint: disable=unused-argument
if self.cost > self.maximum_cost:
self.context.report_error(self.get_cost_exceeded_error())
diff --git a/saleor/graphql/discount/mutations/promotion/promotion_rule_update.py b/saleor/graphql/discount/mutations/promotion/promotion_rule_update.py
index a8da7f770f..ea424b6259 100644
--- a/saleor/graphql/discount/mutations/promotion/promotion_rule_update.py
+++ b/saleor/graphql/discount/mutations/promotion/promotion_rule_update.py
@@ -156,9 +156,7 @@ class PromotionRuleUpdate(ModelMutation):
if "reward_value_type" in cleaned_input
else "add_channels"
)
- error_code = (
- PromotionRuleUpdateErrorCode.MULTIPLE_CURRENCIES_NOT_ALLOWED.value
- )
+ error_code = PromotionRuleUpdateErrorCode.MULTIPLE_CURRENCIES_NOT_ALLOWED.value
raise ValidationError(
{
field: ValidationError(
diff --git a/saleor/graphql/order/mutations/draft_order_create.py b/saleor/graphql/order/mutations/draft_order_create.py
index f91e7addc8..7dda9dfc8b 100644
--- a/saleor/graphql/order/mutations/draft_order_create.py
+++ b/saleor/graphql/order/mutations/draft_order_create.py
@@ -414,7 +414,7 @@ class DraftOrderCreate(
*,
is_new_instance,
app,
- manager
+ manager,
):
updated_fields = []
with traced_atomic_transaction():
diff --git a/saleor/graphql/order/mutations/fulfillment_approve.py b/saleor/graphql/order/mutations/fulfillment_approve.py
index 728b1637c8..a87c1cec43 100644
--- a/saleor/graphql/order/mutations/fulfillment_approve.py
+++ b/saleor/graphql/order/mutations/fulfillment_approve.py
@@ -79,7 +79,7 @@ class FulfillmentApprove(BaseMutation):
*,
allow_stock_to_be_exceeded,
id: str,
- notify_customer
+ notify_customer,
):
user = info.context.user
user = cast(User, user)
diff --git a/saleor/graphql/order/tests/queries/test_order.py b/saleor/graphql/order/tests/queries/test_order.py
index 666369a3dc..0349f4828f 100644
--- a/saleor/graphql/order/tests/queries/test_order.py
+++ b/saleor/graphql/order/tests/queries/test_order.py
@@ -366,8 +366,9 @@ def test_order_query(
)
assert float(expected_shipping_price.price.amount) == method["price"]["amount"]
- assert float(expected_shipping_price.minimum_order_price.amount) == (
- method["minimumOrderPrice"]["amount"]
+ assert (
+ float(expected_shipping_price.minimum_order_price.amount)
+ == (method["minimumOrderPrice"]["amount"])
)
assert order_data["deliveryMethod"]["id"] == order_data["shippingMethod"]["id"]
assert order_data["checkoutId"] == (
@@ -994,8 +995,9 @@ def test_order_query_in_pln_channel(
channel_id=order.channel_id
)
assert float(expected_shipping_price.price.amount) == method["price"]["amount"]
- assert float(expected_shipping_price.minimum_order_price.amount) == (
- method["minimumOrderPrice"]["amount"]
+ assert (
+ float(expected_shipping_price.minimum_order_price.amount)
+ == (method["minimumOrderPrice"]["amount"])
)
diff --git a/saleor/graphql/order/tests/queries/test_order_with_filter.py b/saleor/graphql/order/tests/queries/test_order_with_filter.py
index d3cb61a5c1..85046d7351 100644
--- a/saleor/graphql/order/tests/queries/test_order_with_filter.py
+++ b/saleor/graphql/order/tests/queries/test_order_with_filter.py
@@ -739,13 +739,15 @@ def test_orders_query_with_filter_search_by_global_payment_id(
),
]
)
- OrderDiscount.objects.create(
- order=orders[0],
- name="test_discount1",
- value=Decimal("1"),
- amount_value=Decimal("1"),
- translated_name="translated_discount1_name",
- ),
+ (
+ OrderDiscount.objects.create(
+ order=orders[0],
+ name="test_discount1",
+ value=Decimal("1"),
+ amount_value=Decimal("1"),
+ translated_name="translated_discount1_name",
+ ),
+ )
order_with_payment = orders[0]
payment = Payment.objects.create(order=order_with_payment)
diff --git a/saleor/graphql/payment/mutations/transaction/transaction_initialize.py b/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
index 662320efed..738ba7d23b 100644
--- a/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
+++ b/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
@@ -115,7 +115,7 @@ class TransactionInitialize(TransactionSessionBase):
payment_gateway,
amount=None,
action=None,
- customer_ip_address=None
+ customer_ip_address=None,
):
manager = get_plugin_manager_promise(info.context).get()
payment_gateway_data = PaymentGatewayData(
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index 7bf4e42315..81e658c35c 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -473,7 +473,7 @@ class ProductAttributeAssignmentUpdate(BaseMutation, VariantAssignmentValidation
@classmethod
def clean_operations(cls, product_type, variant_attrs_data):
errors: DefaultDict[str, List[ValidationError]] = defaultdict(list)
- variant_attrs_pks = [pk for pk, _, in variant_attrs_data]
+ variant_attrs_pks = [pk for pk, _ in variant_attrs_data]
cls.check_for_duplicates(errors, variant_attrs_pks)
if errors:
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_delete.py b/saleor/graphql/product/mutations/product_variant/product_variant_delete.py
index 24bb0684e9..8d065ed940 100644
--- a/saleor/graphql/product/mutations/product_variant/product_variant_delete.py
+++ b/saleor/graphql/product/mutations/product_variant/product_variant_delete.py
@@ -73,7 +73,7 @@ class ProductVariantDelete(ModelDeleteMutation, ModelWithExtRefMutation):
*,
external_reference: Optional[str] = None,
id: Optional[str] = None,
- sku: Optional[str] = None
+ sku: Optional[str] = None,
):
validate_one_of_args_is_in_mutation(
"sku",
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_update.py b/saleor/graphql/product/mutations/product_variant/product_variant_update.py
index 135d6f4561..0d675ad01d 100644
--- a/saleor/graphql/product/mutations/product_variant/product_variant_update.py
+++ b/saleor/graphql/product/mutations/product_variant/product_variant_update.py
@@ -143,7 +143,7 @@ class ProductVariantUpdate(ProductVariantCreate, ModelWithExtRefMutation):
external_reference=None,
id=None,
sku=None,
- input
+ input,
):
validate_one_of_args_is_in_mutation(
"sku",
diff --git a/saleor/graphql/product/resolvers.py b/saleor/graphql/product/resolvers.py
index 4b8856c3a7..3e6bacf60f 100644
--- a/saleor/graphql/product/resolvers.py
+++ b/saleor/graphql/product/resolvers.py
@@ -108,7 +108,7 @@ def resolve_variant(
*,
channel_slug,
requestor,
- requestor_has_access_to_all
+ requestor_has_access_to_all,
):
visible_products = models.Product.objects.visible_to_user(
requestor, channel_slug
diff --git a/saleor/graphql/product/tests/queries/test_variant_query.py b/saleor/graphql/product/tests/queries/test_variant_query.py
index 72f8aa7001..5ca84cc430 100644
--- a/saleor/graphql/product/tests/queries/test_variant_query.py
+++ b/saleor/graphql/product/tests/queries/test_variant_query.py
@@ -635,9 +635,7 @@ def test_variant_restricted_fields_permissions(
%(field)s
}
}
- """ % {
- "field": field if not is_nested else "%s { __typename }" % field
- }
+ """ % {"field": field if not is_nested else "%s { __typename }" % field}
variant = product.variants.first()
variables = {
"id": graphene.Node.to_global_id("ProductVariant", variant.pk),
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 37da32bfed..9fdfaad7f3 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -1064,7 +1064,7 @@ class Product(ChannelContextTypeWithMetadata[models.Product]):
info,
*,
size: int = 256,
- format: Optional[str] = None
+ format: Optional[str] = None,
):
format = get_thumbnail_format(format)
size = get_thumbnail_size(size)
@@ -1819,7 +1819,7 @@ class ProductMedia(ModelObjectType[models.ProductMedia]):
info,
*,
size: Optional[int] = None,
- format: Optional[str] = None
+ format: Optional[str] = None,
):
if root.external_url:
return root.external_url
@@ -1885,7 +1885,7 @@ class ProductImage(BaseObjectType):
info,
*,
size: Optional[int] = None,
- format: Optional[str] = None
+ format: Optional[str] = None,
):
if not root.image:
return
diff --git a/saleor/graphql/translations/mutations/utils.py b/saleor/graphql/translations/mutations/utils.py
index 127b2fe64e..40594748a6 100644
--- a/saleor/graphql/translations/mutations/utils.py
+++ b/saleor/graphql/translations/mutations/utils.py
@@ -177,7 +177,7 @@ class BaseBulkTranslateMutation(BaseMutation):
base_model_relation_field=None,
result_type=None,
_meta=None,
- **kwargs
+ **kwargs,
):
if not base_model:
raise ImproperlyConfigured(
diff --git a/saleor/invoice/events.py b/saleor/invoice/events.py
index a4d40b3822..2bc2a960b9 100644
--- a/saleor/invoice/events.py
+++ b/saleor/invoice/events.py
@@ -59,7 +59,7 @@ def notification_invoice_sent_event(
user_id: Optional[int],
app_id: Optional[int],
invoice_id: int,
- customer_email: str
+ customer_email: str,
) -> InvoiceEvent:
return InvoiceEvent.objects.create(
type=InvoiceEvents.SENT,
diff --git a/saleor/order/events.py b/saleor/order/events.py
index 979f209d39..cb3e49afa2 100644
--- a/saleor/order/events.py
+++ b/saleor/order/events.py
@@ -220,7 +220,7 @@ def invoice_updated_event(
app: Optional[App],
invoice_number: str,
url: str,
- status: str
+ status: str,
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -263,7 +263,7 @@ def order_added_products_event(
user: Optional[User],
app: Optional[App],
order_lines: List[OrderLine],
- quantity_diff: Optional[int] = None
+ quantity_diff: Optional[int] = None,
) -> OrderEvent:
if quantity_diff:
lines = [_line_per_quantity_to_line_object(quantity_diff, order_lines[0])]
@@ -285,7 +285,7 @@ def order_removed_products_event(
user: Optional[User],
app: Optional[App],
order_lines: List[OrderLine],
- quantity_diff: Optional[int] = None
+ quantity_diff: Optional[int] = None,
) -> OrderEvent:
if quantity_diff:
lines = [_line_per_quantity_to_line_object(quantity_diff, order_lines[0])]
@@ -307,7 +307,7 @@ def draft_order_created_from_replace_event(
original_order: Order,
user: Optional[User],
app: Optional[App],
- lines: List[OrderLine]
+ lines: List[OrderLine],
):
parameters = {
"related_order_pk": original_order.pk,
@@ -359,7 +359,7 @@ def order_manually_marked_as_paid_event(
order: Order,
user: Optional[User],
app: Optional[App],
- transaction_reference: Optional[str] = None
+ transaction_reference: Optional[str] = None,
) -> OrderEvent:
parameters = {}
if transaction_reference:
@@ -386,7 +386,7 @@ def order_replacement_created(
original_order: Order,
replace_order: Order,
user: Optional[User],
- app: Optional[App]
+ app: Optional[App],
) -> OrderEvent:
parameters = {"related_order_pk": replace_order.pk}
return OrderEvent.objects.create(
@@ -404,7 +404,7 @@ def payment_authorized_event(
user: Optional[User],
app: Optional[App],
amount: Decimal,
- payment: Payment
+ payment: Payment,
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -421,7 +421,7 @@ def payment_captured_event(
user: Optional[User],
app: Optional[App],
amount: Decimal,
- payment: Payment
+ payment: Payment,
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -438,7 +438,7 @@ def payment_refunded_event(
user: Optional[User],
app: Optional[App],
amount: Decimal,
- payment: Payment
+ payment: Payment,
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -467,7 +467,7 @@ def payment_failed_event(
user: Optional[User],
app: Optional[App],
message: str,
- payment: Payment
+ payment: Payment,
) -> OrderEvent:
parameters = {"message": message}
@@ -503,7 +503,7 @@ def transaction_event(
user: Optional[User],
app: Optional[App],
reference: str,
- message: str
+ message: str,
) -> OrderEvent:
parameters = {"message": message, "reference": reference}
return OrderEvent.objects.create(
@@ -521,7 +521,7 @@ def external_notification_event(
user: Optional[User],
app: Optional[App],
message: Optional[str],
- parameters: Optional[dict]
+ parameters: Optional[dict],
) -> OrderEvent:
parameters = parameters or {}
parameters["message"] = message
@@ -540,7 +540,7 @@ def fulfillment_canceled_event(
order: Order,
user: Optional[User],
app: Optional[App],
- fulfillment: Optional[Fulfillment]
+ fulfillment: Optional[Fulfillment],
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -576,7 +576,7 @@ def fulfillment_fulfilled_items_event(
order: Order,
user: Optional[User],
app: Optional[App],
- fulfillment_lines: List[FulfillmentLine]
+ fulfillment_lines: List[FulfillmentLine],
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -592,7 +592,7 @@ def fulfillment_awaits_approval_event(
order: Order,
user: Optional[User],
app: Optional[App],
- fulfillment_lines: List[FulfillmentLine]
+ fulfillment_lines: List[FulfillmentLine],
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -647,7 +647,7 @@ def fulfillment_refunded_event(
app: Optional[App],
refunded_lines: List[Tuple[int, OrderLine]],
amount: Decimal,
- shipping_costs_included: bool
+ shipping_costs_included: bool,
):
return OrderEvent.objects.create(
order=order,
@@ -671,7 +671,7 @@ def fulfillment_tracking_updated_event(
user: Optional[User],
app: Optional[App],
tracking_number: str,
- fulfillment: Fulfillment
+ fulfillment: Fulfillment,
) -> OrderEvent:
return OrderEvent.objects.create(
order=order,
@@ -747,7 +747,7 @@ def order_discount_event(
user: Optional[User],
app: Optional[App],
order_discount: "OrderDiscount",
- old_order_discount: Optional["OrderDiscount"] = None
+ old_order_discount: Optional["OrderDiscount"] = None,
) -> OrderEvent:
discount_parameters = _prepare_discount_object(order_discount, old_order_discount)
@@ -838,7 +838,7 @@ def order_line_discount_event(
user: Optional[User],
app: Optional[App],
line: OrderLine,
- line_before_update: Optional["OrderLine"] = None
+ line_before_update: Optional["OrderLine"] = None,
) -> OrderEvent:
discount_parameters = {
"value": line.unit_discount_value,
diff --git a/saleor/order/tasks.py b/saleor/order/tasks.py
index 664901000b..1651cc7b94 100644
--- a/saleor/order/tasks.py
+++ b/saleor/order/tasks.py
@@ -56,9 +56,9 @@ def _bulk_release_voucher_usage(order_ids):
Voucher.objects.filter(
Exists(voucher_orders),
usage_limit__isnull=False,
- ).annotate(
- order_count=Subquery(count_orders)
- ).update(used=F("used") - F("order_count"))
+ ).annotate(order_count=Subquery(count_orders)).update(
+ used=F("used") - F("order_count")
+ )
voucher_customer_orders = Order.objects.filter(
voucher=OuterRef("voucher__id"),
diff --git a/saleor/payment/gateway.py b/saleor/payment/gateway.py
index 180e9219bc..475c8eb4d4 100644
--- a/saleor/payment/gateway.py
+++ b/saleor/payment/gateway.py
@@ -506,7 +506,8 @@ def _fetch_gateway_response(fn, *args, **kwargs):
def _get_past_transaction_token(
- payment: Payment, kind: str # for kind use "TransactionKind"
+ payment: Payment,
+ kind: str, # for kind use "TransactionKind"
) -> str:
txn = payment.transactions.filter(kind=kind, is_success=True).last()
if txn is None:
diff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.py
index dc1d181bc0..79869cd30b 100644
--- a/saleor/payment/gateways/stripe/plugin.py
+++ b/saleor/payment/gateways/stripe/plugin.py
@@ -528,7 +528,8 @@ class StripeGatewayPlugin(BasePlugin):
webhook = None
if not webhook_id and not webhook_secret_data.get("value"):
webhook = subscribe_webhook(
- api_key, plugin_configuration.channel.slug # type: ignore
+ api_key,
+ plugin_configuration.channel.slug, # type: ignore
)
if not webhook:
diff --git a/saleor/permission/management.py b/saleor/permission/management.py
index f0e43f7b26..b655ad6bec 100644
--- a/saleor/permission/management.py
+++ b/saleor/permission/management.py
@@ -33,7 +33,7 @@ def create_permissions(
interactive=True,
using=DEFAULT_DB_ALIAS,
apps=global_apps,
- **kwargs
+ **kwargs,
):
if not app_config.models_module:
return
diff --git a/saleor/plugins/avatax/tests/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index eae87df1b3..d55d036279 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -3898,9 +3898,7 @@ def test_get_order_shipping_tax_rate_shipping_with_tax_class(
order.shipping_tax_class = method.tax_class
order.shipping_tax_class_name = method.tax_class.name
order.shipping_tax_class_metadata = method.tax_class.metadata
- order.shipping_tax_class_private_metadata = (
- method.tax_class.private_metadata
- ) # noqa: E501
+ order.shipping_tax_class_private_metadata = method.tax_class.private_metadata # noqa: E501
order.save()
# when
diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.py
index 8b2cb651b3..2192e05df2 100644
--- a/saleor/plugins/manager.py
+++ b/saleor/plugins/manager.py
@@ -229,9 +229,7 @@ class PluginsManager(PaymentInterface):
plugin_method = getattr(plugin, method_name, NotImplemented)
if plugin_method == NotImplemented:
return previous_value
- returned_value = plugin_method(
- *args, **kwargs, previous_value=previous_value
- ) # type:ignore
+ returned_value = plugin_method(*args, **kwargs, previous_value=previous_value) # type:ignore
if returned_value == NotImplemented:
return previous_value
return returned_value
diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.py
index 629f051577..01229cfe36 100644
--- a/saleor/plugins/webhook/plugin.py
+++ b/saleor/plugins/webhook/plugin.py
@@ -2729,7 +2729,7 @@ class WebhookPlugin(BasePlugin):
checkout_info: Optional["CheckoutInfo"],
checkout_lines: Optional[Iterable["CheckoutLineInfo"]],
previous_value,
- **kwargs
+ **kwargs,
) -> List["PaymentGateway"]:
gateways = []
checkout = None
diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.py
index e8a011d5b0..349d772e5a 100644
--- a/saleor/product/utils/availability.py
+++ b/saleor/product/utils/availability.py
@@ -93,7 +93,7 @@ def get_product_availability(
variants_channel_listing: List[ProductVariantChannelListing],
prices_entered_with_tax: bool,
tax_calculation_strategy: str,
- tax_rate: Decimal
+ tax_rate: Decimal,
) -> ProductAvailability:
discounted: Optional[TaxedMoneyRange] = None
discounted_net_range = get_product_price_range(
@@ -159,7 +159,7 @@ def get_variant_availability(
product_channel_listing: Optional[ProductChannelListing],
prices_entered_with_tax: bool,
tax_calculation_strategy: str,
- tax_rate: Decimal
+ tax_rate: Decimal,
) -> Optional[VariantAvailability]:
if variant_channel_listing.price is None:
return None
diff --git a/saleor/shipping/tests/test_shipping.py b/saleor/shipping/tests/test_shipping.py
index f54ae9e2ac..3c018d19a0 100644
--- a/saleor/shipping/tests/test_shipping.py
+++ b/saleor/shipping/tests/test_shipping.py
@@ -242,11 +242,13 @@ def test_applicable_shipping_methods_not_in_channel(shipping_zone, channel_USD):
maximum_order_weight=Weight(kg=10),
type=ShippingMethodType.WEIGHT_BASED,
)
- ShippingMethodChannelListing.objects.create(
- shipping_method=weight_method,
- channel=channel_USD,
- currency=channel_USD.currency_code,
- ),
+ (
+ ShippingMethodChannelListing.objects.create(
+ shipping_method=weight_method,
+ channel=channel_USD,
+ currency=channel_USD.currency_code,
+ ),
+ )
result = ShippingMethod.objects.applicable_shipping_methods(
price=Money("5.0", "USD"),
weight=Weight(kg=5),
diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.py
index b64574e5eb..2b8a71c0a9 100644
--- a/saleor/tests/fixtures.py
+++ b/saleor/tests/fixtures.py
@@ -2011,9 +2011,7 @@ def pink_attribute_value(color_attribute): # pylint: disable=W0613
@pytest.fixture
-def size_attribute(
- db, attribute_generator, attribute_values_generator
-): # pylint: disable=W0613
+def size_attribute(db, attribute_generator, attribute_values_generator): # pylint: disable=W0613
attribute = attribute_generator(
external_reference="sizeAttributeExternalReference",
slug="size",
diff --git a/saleor/webhook/observability/obfuscation.py b/saleor/webhook/observability/obfuscation.py
index 80efcfc841..c1aa74ab8a 100644
--- a/saleor/webhook/observability/obfuscation.py
+++ b/saleor/webhook/observability/obfuscation.py
@@ -71,9 +71,7 @@ class SensitiveFieldError(GraphQLError):
class ContainSensitiveField(ValidationRule):
- def __init__(
- self, sensitive_fields: SensitiveFieldsMap
- ): # pylint: disable=super-init-not-called
+ def __init__(self, sensitive_fields: SensitiveFieldsMap): # pylint: disable=super-init-not-called
self.sensitive_fields = sensitive_fields
def __call__(self, context: ValidationContext):
@@ -120,9 +118,7 @@ class ContainSensitiveField(ValidationRule):
self.contain_sensitive_field(child_node, inline_fragment_type)
return False
- def enter_operation_definition(
- self, node, key, parent, path, ancestors
- ): # pylint: disable=unused-argument
+ def enter_operation_definition(self, node, key, parent, path, ancestors): # pylint: disable=unused-argument
validate_sensitive_fields_map(self.sensitive_fields, self.context.get_schema())
if node.operation == "query":
self.contain_sensitive_field(