Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use ruff to lint Saleor (#11143)
Patryk Zawadzki938f0c027422
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 65ba563dda..dcc9535469 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -15,10 +15,10 @@ repos:exclude: ^templates/templated_email/compiled/exclude_types: [svg]- - repo: https://gitlab.com/pycqa/flake8- rev: 3.9.2+ - repo: https://github.com/charliermarsh/ruff-pre-commit+ rev: v0.0.106hooks:- - id: flake8+ - id: ruff- repo: https://github.com/pycqa/isortrev: 5.10.1diff --git a/.vscode/extensions.json b/.vscode/extensions.jsonindex db619bc69b..d0f74a7764 100644--- a/.vscode/extensions.json+++ b/.vscode/extensions.json@@ -1,5 +1,6 @@{"recommendations": [+ "charliermarsh.ruff","editorconfig.editorconfig","github.vscode-pull-request-github","ms-python.black-formatter",diff --git a/saleor/account/migrations/0001_initial.py b/saleor/account/migrations/0001_initial.pyindex 8345eaf6ac..c9e334ec8a 100644--- a/saleor/account/migrations/0001_initial.py+++ b/saleor/account/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsimport django.db.models.deletiondiff --git a/saleor/account/migrations/0002_auto_20150907_0602.py b/saleor/account/migrations/0002_auto_20150907_0602.pyindex 213150e51e..5b8a0f16da 100644--- a/saleor/account/migrations/0002_auto_20150907_0602.py+++ b/saleor/account/migrations/0002_auto_20150907_0602.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/account/migrations/0003_auto_20151104_1102.py b/saleor/account/migrations/0003_auto_20151104_1102.pyindex 2920381e36..1104a71b42 100644--- a/saleor/account/migrations/0003_auto_20151104_1102.py+++ b/saleor/account/migrations/0003_auto_20151104_1102.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/account/migrations/0004_auto_20160114_0419.py b/saleor/account/migrations/0004_auto_20160114_0419.pyindex 6745ef09e9..eabf20dc96 100644--- a/saleor/account/migrations/0004_auto_20160114_0419.py+++ b/saleor/account/migrations/0004_auto_20160114_0419.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-14 10:19from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0005_auto_20160205_0651.py b/saleor/account/migrations/0005_auto_20160205_0651.pyindex 561e913232..8c794dfb6a 100644--- a/saleor/account/migrations/0005_auto_20160205_0651.py+++ b/saleor/account/migrations/0005_auto_20160205_0651.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.2 on 2016-02-05 12:51from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0006_auto_20160829_0819.py b/saleor/account/migrations/0006_auto_20160829_0819.pyindex b4ee939bdc..882d7f57fb 100644--- a/saleor/account/migrations/0006_auto_20160829_0819.py+++ b/saleor/account/migrations/0006_auto_20160829_0819.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10 on 2016-08-29 13:19from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0007_auto_20161115_0940.py b/saleor/account/migrations/0007_auto_20161115_0940.pyindex 9c2235cc6b..34fa1b3a6c 100644--- a/saleor/account/migrations/0007_auto_20161115_0940.py+++ b/saleor/account/migrations/0007_auto_20161115_0940.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-11-15 15:40from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0008_auto_20161115_1011.py b/saleor/account/migrations/0008_auto_20161115_1011.pyindex 85545f7604..261e85c722 100644--- a/saleor/account/migrations/0008_auto_20161115_1011.py+++ b/saleor/account/migrations/0008_auto_20161115_1011.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-11-15 16:11from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0009_auto_20170206_0407.py b/saleor/account/migrations/0009_auto_20170206_0407.pyindex aadb44f602..230399f822 100644--- a/saleor/account/migrations/0009_auto_20170206_0407.py+++ b/saleor/account/migrations/0009_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0010_auto_20170919_0839.py b/saleor/account/migrations/0010_auto_20170919_0839.pyindex 81dfe24e9b..d215d25d28 100644--- a/saleor/account/migrations/0010_auto_20170919_0839.py+++ b/saleor/account/migrations/0010_auto_20170919_0839.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-19 13:39from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0011_auto_20171110_0552.py b/saleor/account/migrations/0011_auto_20171110_0552.pyindex 1ad132e9f4..301a19addf 100644--- a/saleor/account/migrations/0011_auto_20171110_0552.py+++ b/saleor/account/migrations/0011_auto_20171110_0552.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-10 11:52from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0012_auto_20171117_0846.py b/saleor/account/migrations/0012_auto_20171117_0846.pyindex 605b10cc3e..2654c0d8b6 100644--- a/saleor/account/migrations/0012_auto_20171117_0846.py+++ b/saleor/account/migrations/0012_auto_20171117_0846.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-17 14:46from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0013_auto_20171120_0521.py b/saleor/account/migrations/0013_auto_20171120_0521.pyindex c8dac4ea97..03ed971af2 100644--- a/saleor/account/migrations/0013_auto_20171120_0521.py+++ b/saleor/account/migrations/0013_auto_20171120_0521.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-20 11:21from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0014_auto_20171129_1004.py b/saleor/account/migrations/0014_auto_20171129_1004.pyindex 0d37810b73..4384eafbb1 100644--- a/saleor/account/migrations/0014_auto_20171129_1004.py+++ b/saleor/account/migrations/0014_auto_20171129_1004.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0015_auto_20171213_0734.py b/saleor/account/migrations/0015_auto_20171213_0734.pyindex d17df20b42..5edd63838f 100644--- a/saleor/account/migrations/0015_auto_20171213_0734.py+++ b/saleor/account/migrations/0015_auto_20171213_0734.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-13 13:34from __future__ import unicode_literalsdiff --git a/saleor/account/migrations/0016_auto_20180108_0814.py b/saleor/account/migrations/0016_auto_20180108_0814.pyindex 53b6b17369..e4cfed3c61 100644--- a/saleor/account/migrations/0016_auto_20180108_0814.py+++ b/saleor/account/migrations/0016_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0001_auto_20170113_0435.py b/saleor/checkout/migrations/0001_auto_20170113_0435.pyindex 128d5ad580..839c69510c 100644--- a/saleor/checkout/migrations/0001_auto_20170113_0435.py+++ b/saleor/checkout/migrations/0001_auto_20170113_0435.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2017-01-13 10:35from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0001_initial.py b/saleor/checkout/migrations/0001_initial.pyindex d25ece23d3..8998862b41 100644--- a/saleor/checkout/migrations/0001_initial.py+++ b/saleor/checkout/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsimport uuiddiff --git a/saleor/checkout/migrations/0002_auto_20161014_1221.py b/saleor/checkout/migrations/0002_auto_20161014_1221.pyindex df978e07a2..bf0ae8d1dd 100644--- a/saleor/checkout/migrations/0002_auto_20161014_1221.py+++ b/saleor/checkout/migrations/0002_auto_20161014_1221.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-10-14 17:21from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0002_auto_20170206_0407.py b/saleor/checkout/migrations/0002_auto_20170206_0407.pyindex 1cdd139008..51d4a5bb7b 100644--- a/saleor/checkout/migrations/0002_auto_20170206_0407.py+++ b/saleor/checkout/migrations/0002_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0003_auto_20170906_0556.py b/saleor/checkout/migrations/0003_auto_20170906_0556.pyindex b259e9fc80..2d52226d23 100644--- a/saleor/checkout/migrations/0003_auto_20170906_0556.py+++ b/saleor/checkout/migrations/0003_auto_20170906_0556.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-06 10:56from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0004_auto_20171129_1004.py b/saleor/checkout/migrations/0004_auto_20171129_1004.pyindex e7d819fa1a..2b8d1609b9 100644--- a/saleor/checkout/migrations/0004_auto_20171129_1004.py+++ b/saleor/checkout/migrations/0004_auto_20171129_1004.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/0005_auto_20180108_0814.py b/saleor/checkout/migrations/0005_auto_20180108_0814.pyindex 91b9cc7858..7ec3e77f73 100644--- a/saleor/checkout/migrations/0005_auto_20180108_0814.py+++ b/saleor/checkout/migrations/0005_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/checkout/migrations/fix_empty_data_in_lines.py b/saleor/checkout/migrations/fix_empty_data_in_lines.pyindex f5cb1ccbfa..cddfd7c225 100644--- a/saleor/checkout/migrations/fix_empty_data_in_lines.py+++ b/saleor/checkout/migrations/fix_empty_data_in_lines.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-06 13:02from __future__ import unicode_literalsdiff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex 6956128851..cd9eba5fbb 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -8,7 +8,6 @@ from uuid import uuid4from django.conf import settingsfrom django.core.validators import MinValueValidatorfrom django.db import models-from django.db.models.deletion import SET_NULLfrom django.utils import timezonefrom django.utils.encoding import smart_strfrom django_countries.fields import Country, CountryField@@ -24,7 +23,6 @@ from ..giftcard.models import GiftCardfrom ..shipping.models import ShippingMethodif TYPE_CHECKING:- # flake8: noqafrom django_measurement import Weightfrom ..payment.models import Paymentdiff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 0dd961d93a..0dcfaa246f 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -18,10 +18,7 @@ from ..core.utils.promo_code import (from ..discount import DiscountInfo, VoucherTypefrom ..discount.interface import VoucherInfo, fetch_voucher_infofrom ..discount.models import NotApplicable, Voucher-from ..discount.utils import (- get_products_voucher_discount,- validate_voucher_for_checkout,-)+from ..discount.utils import validate_voucher_for_checkoutfrom ..giftcard.utils import (add_gift_card_code_to_checkout,remove_gift_card_code_from_checkout,@@ -43,13 +40,9 @@ from .fetch import (from .models import Checkout, CheckoutLineif TYPE_CHECKING:- # flake8: noqafrom decimal import Decimal- from prices import TaxedMoney-from ..account.models import Address- from ..channel.models import Channelfrom ..order.models import Orderfrom .fetch import CheckoutInfo, CheckoutLineInfodiff --git a/saleor/core/payments.py b/saleor/core/payments.pyindex 78caab7df3..64f66b6218 100644--- a/saleor/core/payments.py+++ b/saleor/core/payments.py@@ -2,7 +2,6 @@ from abc import ABC, abstractmethodfrom typing import TYPE_CHECKING, List, Optionalif TYPE_CHECKING:- # flake8: noqafrom ..checkout.models import Checkoutfrom ..payment.interface import (CustomerSource,diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.pyindex 3f18945d07..c24ebb635f 100644--- a/saleor/core/utils/__init__.py+++ b/saleor/core/utils/__init__.py@@ -1,6 +1,6 @@import osimport socket-from typing import TYPE_CHECKING, Iterable, Optional, Type, Union+from typing import TYPE_CHECKING, Iterable, Optional, Unionfrom urllib.parse import urljoinfrom babel.numbers import get_territory_currencies@@ -18,7 +18,6 @@ task_logger = get_task_logger(__name__)if TYPE_CHECKING:- # flake8: noqa: F401from django.utils.safestring import SafeTextdiff --git a/saleor/core/utils/editorjs.py b/saleor/core/utils/editorjs.pyindex 92431cc969..599ea7013c 100644--- a/saleor/core/utils/editorjs.py+++ b/saleor/core/utils/editorjs.py@@ -55,14 +55,14 @@ def clean_editor_js(definitions: Optional[Dict], *, to_string: bool = False):return " ".join(plain_text_list) if to_string else definitions-def clean_text_data(text: str):+def clean_text_data(text: str) -> str:"""Look for url in text, check if URL is allowed and return the cleaned URL.By default, only the protocol ``javascript`` is denied."""if not text:- return+ return textend_of_match = 0new_text = ""diff --git a/saleor/csv/utils/export.py b/saleor/csv/utils/export.pyindex 33a25c8e12..52cf0eea15 100644--- a/saleor/csv/utils/export.py+++ b/saleor/csv/utils/export.py@@ -14,7 +14,6 @@ from .product_headers import get_product_export_fields_and_headers_infofrom .products_data import get_products_dataif TYPE_CHECKING:- # flake8: noqafrom django.db.models import QuerySetfrom ..models import ExportFile@@ -110,7 +109,10 @@ def get_queryset(model, filter, scope: Dict[str, Union[str, dict]]) -> "QuerySetdef parse_input(data: Any) -> Dict[str, Union[str, dict]]:- """Parse input to correct data types, since scope coming from celery will be parsed to strings."""+ """Parse input into correct data types.++ Scope coming from Celery will be passed as strings.+ """if "attributes" in data:serialized_attributes = []diff --git a/saleor/demo/settings.py b/saleor/demo/settings.pyindex 2229ec0aa0..3efb267e15 100644--- a/saleor/demo/settings.py+++ b/saleor/demo/settings.py@@ -12,23 +12,26 @@ for more details)GraphQL query"""-# flake8: noqa: F405import logging+import osimport re+import sentry_sdkfrom sentry_sdk.integrations.celery import CeleryIntegration+from sentry_sdk.integrations.django import DjangoIntegrationfrom sentry_sdk.integrations.logging import ignore_logger-from ..settings import * # noqa: F403, lgtm [py/polluting-import]+from ..settings import * # noqa: F403logger = logging.getLogger(__name__)+# Override urls to use different GraphQL view on demoROOT_URLCONF = "saleor.demo.urls"-PLUGINS += ["saleor.plugins.anonymize.plugin.AnonymizePlugin"]+PLUGINS += ["saleor.plugins.anonymize.plugin.AnonymizePlugin"] # noqa: F405-GRAPHENE.setdefault("MIDDLEWARE", []).insert( # type: ignore+GRAPHENE.setdefault("MIDDLEWARE", []).insert( # type: ignore # noqa: F4050, "saleor.graphql.middleware.ReadOnlyMiddleware")@@ -42,7 +45,7 @@ if not (BRAINTREE_API_KEY and BRAINTREE_MERCHANT_ID and BRAINTREE_SECRET_API_KEY"sandbox configuration in the demo mode with `populatedb` command.")-PWA_ORIGINS = get_list(os.environ.get("PWA_ORIGINS", "demo.saleor.io"))+PWA_ORIGINS = get_list(os.environ.get("PWA_ORIGINS", "demo.saleor.io")) # noqa: F405PWA_DASHBOARD_URL_RE = re.compile("^https?://[^/]+/dashboard/.*")ROOT_EMAIL = os.environ.get("ROOT_EMAIL")@@ -50,8 +53,8 @@ ROOT_EMAIL = os.environ.get("ROOT_EMAIL")# Remove "saleor.core" and add it after adding "saleor.demo", to have "populatedb"# command overridden when using demo settings# (see saleor.demo.management.commands.populatedb).-INSTALLED_APPS.remove("saleor.core")-INSTALLED_APPS += ["saleor.demo", "saleor.core"]+INSTALLED_APPS.remove("saleor.core") # noqa: F405+INSTALLED_APPS += ["saleor.demo", "saleor.core"] # noqa: F405ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL = Falsediff --git a/saleor/discount/__init__.py b/saleor/discount/__init__.pyindex 11bc143191..1f2641bdf2 100644--- a/saleor/discount/__init__.py+++ b/saleor/discount/__init__.py@@ -1,11 +1,8 @@from dataclasses import dataclass-from typing import TYPE_CHECKING, Dict, Iterable, List, Set, Union--from django.conf import settings+from typing import TYPE_CHECKING, Dict, List, Set, Unionif TYPE_CHECKING:- # flake8: noqa- from .models import Sale, SaleChannelListing, Voucher+ from .models import Sale, SaleChannelListingclass DiscountValueType:@@ -38,7 +35,7 @@ class VoucherType:@dataclassclass DiscountInfo:- sale: Union["Sale", "Voucher"]+ sale: "Sale"channel_listings: Dict[str, "SaleChannelListing"]product_ids: Union[List[int], Set[int]]category_ids: Union[List[int], Set[int]]diff --git a/saleor/discount/migrations/0001_initial.py b/saleor/discount/migrations/0001_initial.pyindex 4498a2a32d..09a78128e0 100644--- a/saleor/discount/migrations/0001_initial.py+++ b/saleor/discount/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-29 14:26from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0002_voucher.py b/saleor/discount/migrations/0002_voucher.pyindex 405fb4940d..238dd6a17a 100644--- a/saleor/discount/migrations/0002_voucher.py+++ b/saleor/discount/migrations/0002_voucher.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-02-04 17:07from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0003_auto_20160207_0534.py b/saleor/discount/migrations/0003_auto_20160207_0534.pyindex 4a5b2dee0c..09eda20f34 100644--- a/saleor/discount/migrations/0003_auto_20160207_0534.py+++ b/saleor/discount/migrations/0003_auto_20160207_0534.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-02-07 11:34from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0004_auto_20170206_0407.py b/saleor/discount/migrations/0004_auto_20170206_0407.pyindex 99ee61e8f4..1ae320b5a5 100644--- a/saleor/discount/migrations/0004_auto_20170206_0407.py+++ b/saleor/discount/migrations/0004_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0005_auto_20170919_0839.py b/saleor/discount/migrations/0005_auto_20170919_0839.pyindex 15947bb980..80c748e1b0 100644--- a/saleor/discount/migrations/0005_auto_20170919_0839.py+++ b/saleor/discount/migrations/0005_auto_20170919_0839.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-19 13:39from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0006_auto_20171129_1004.py b/saleor/discount/migrations/0006_auto_20171129_1004.pyindex ade530b9e4..d7df3481ad 100644--- a/saleor/discount/migrations/0006_auto_20171129_1004.py+++ b/saleor/discount/migrations/0006_auto_20171129_1004.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04from __future__ import unicode_literalsdiff --git a/saleor/discount/migrations/0007_auto_20180108_0814.py b/saleor/discount/migrations/0007_auto_20180108_0814.pyindex 7afdeb68a7..06fb8f5847 100644--- a/saleor/discount/migrations/0007_auto_20180108_0814.py+++ b/saleor/discount/migrations/0007_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/discount/utils.py b/saleor/discount/utils.pyindex f1fd79a88a..f5e07c770e 100644--- a/saleor/discount/utils.py+++ b/saleor/discount/utils.py@@ -33,7 +33,6 @@ from .models import ()if TYPE_CHECKING:- # flake8: noqafrom ..account.models import Userfrom ..checkout.fetch import CheckoutInfo, CheckoutLineInfofrom ..order.models import Order@@ -93,12 +92,12 @@ def get_product_discount_on_sale(is_product_on_sale = (product.id in discount.product_idsor product.category_id in discount.category_ids- or product_collections.intersection(discount.collection_ids)+ or bool(product_collections.intersection(discount.collection_ids)))is_variant_on_sale = variant_id and variant_id in discount.variants_idsif is_product_on_sale or is_variant_on_sale:sale_channel_listing = discount.channel_listings.get(channel.slug)- return discount.sale.id, discount.sale.get_discount(sale_channel_listing) # type: ignore+ return discount.sale.id, discount.sale.get_discount(sale_channel_listing)raise NotApplicable("Discount not applicable for this product")@@ -112,7 +111,7 @@ def get_product_discounts() -> Iterator[Tuple[int, Callable]]:"""Return sale ids, discount values for all discounts applicable to a product."""product_collections = set(pc.id for pc in collections)- for discount in discounts or []:+ for discount in discounts:try:yield get_product_discount_on_sale(product, product_collections, discount, channel, variant_id=variant_iddiff --git a/saleor/graphql/account/tests/test_account.py b/saleor/graphql/account/tests/test_account.pyindex edfc9ca0e7..6a0bdcbc3f 100644--- a/saleor/graphql/account/tests/test_account.py+++ b/saleor/graphql/account/tests/test_account.py@@ -1225,7 +1225,7 @@ def test_me_checkout_tokens_without_channel_param_inactive_channel(content = get_graphql_content(response)data = content["data"]["me"]assert str(checkouts[0].token) in data["checkoutTokens"]- assert not str(checkouts[1].token) in data["checkoutTokens"]+ assert str(checkouts[1].token) not in data["checkoutTokens"]def test_me_checkout_tokens_with_channel(@@ -1243,7 +1243,7 @@ def test_me_checkout_tokens_with_channel(content = get_graphql_content(response)data = content["data"]["me"]assert str(checkouts[0].token) in data["checkoutTokens"]- assert not str(checkouts[1].token) in data["checkoutTokens"]+ assert str(checkouts[1].token) not in data["checkoutTokens"]def test_me_checkout_tokens_with_inactive_channel(diff --git a/saleor/graphql/account/tests/test_account_utils.py b/saleor/graphql/account/tests/test_account_utils.pyindex 248b669185..513e13a923 100644--- a/saleor/graphql/account/tests/test_account_utils.py+++ b/saleor/graphql/account/tests/test_account_utils.py@@ -738,8 +738,7 @@ def test_get_not_manageable_permissions_after_removing_perms_from_group_no_permspermission_manage_staff,permission_manage_orders,):- """Ensure no permissions are returned when all perms will be manageable after removing- permissions from group."""+ """Ensure no permissions are lost when after removing permissions from group."""groups = Group.objects.bulk_create([Group(name="manage users and products"),diff --git a/saleor/graphql/attribute/tests/queries/test_attributes_sort.py b/saleor/graphql/attribute/tests/queries/test_attributes_sort.pyindex 67d673b688..4c7b4c5fa6 100644--- a/saleor/graphql/attribute/tests/queries/test_attributes_sort.py+++ b/saleor/graphql/attribute/tests/queries/test_attributes_sort.py@@ -1,5 +1,3 @@-from typing import TYPE_CHECKING, Union-import grapheneimport pytest@@ -8,10 +6,6 @@ from .....attribute.models import Attributefrom .....attribute.utils import associate_attribute_values_to_instancefrom ....tests.utils import get_graphql_content-if TYPE_CHECKING:- from .....product.models import Product, ProductVariant--ATTRIBUTES_SORT_QUERY = """query($sortBy: AttributeSortingInput) {attributes(first: 10, sortBy: $sortBy) {diff --git a/saleor/graphql/core/types/__init__.py b/saleor/graphql/core/types/__init__.pyindex be3010e271..dfeb90211c 100644--- a/saleor/graphql/core/types/__init__.py+++ b/saleor/graphql/core/types/__init__.py@@ -1,4 +1,3 @@-# flake8: noqafrom .common import (TYPES_WITH_DOUBLE_ID_AVAILABLE,AccountError,@@ -61,3 +60,73 @@ from .model import ModelObjectTypefrom .money import VAT, Money, MoneyRange, ReducedRate, TaxedMoney, TaxedMoneyRangefrom .sort_input import ChannelSortInputObjectType, SortInputObjectTypefrom .upload import Upload++__all__ = [+ "AccountError",+ "AppError",+ "AttributeError",+ "BulkProductError",+ "BulkStockError",+ "ChannelError",+ "ChannelErrorCode",+ "CheckoutError",+ "CollectionChannelListingError",+ "CollectionError",+ "CountryDisplay",+ "DateRangeInput",+ "DateTimeRangeInput",+ "DiscountError",+ "Error",+ "ExportError",+ "ExternalNotificationError",+ "File",+ "GiftCardError",+ "GiftCardSettingsError",+ "Image",+ "IntRangeInput",+ "InvoiceError",+ "Job",+ "LanguageDisplay",+ "MenuError",+ "MetadataError",+ "ModelObjectType",+ "Money",+ "MoneyRange",+ "NonNullList",+ "OrderError",+ "OrderSettingsError",+ "PageError",+ "PaymentError",+ "Permission",+ "PermissionGroupError",+ "PluginError",+ "PriceInput",+ "PriceRangeInput",+ "ProductChannelListingError",+ "ProductError",+ "ProductWithoutVariantError",+ "ReducedRate",+ "SeoInput",+ "ShippingError",+ "ShopError",+ "StaffError",+ "StockError",+ "TaxType",+ "TaxedMoney",+ "TaxedMoneyRange",+ "ThumbnailField",+ "TimePeriod",+ "TimePeriodInputType",+ "TranslationError",+ "UploadError",+ "VAT",+ "Weight",+ "WarehouseError",+ "WebhookError",+ "FilterInputObjectType",+ "SortInputObjectType",+ "ChannelFilterInputObjectType",+ "ChannelSortInputObjectType",+ "Upload",+ "TYPES_WITH_DOUBLE_ID_AVAILABLE",+]diff --git a/saleor/graphql/core/utils/__init__.py b/saleor/graphql/core/utils/__init__.pyindex 19884c44f8..07e24ad951 100644--- a/saleor/graphql/core/utils/__init__.py+++ b/saleor/graphql/core/utils/__init__.py@@ -2,14 +2,12 @@ import binasciiimport mimetypesimport osimport secrets-from enum import Enum-from typing import TYPE_CHECKING, Type, Union+from typing import TYPE_CHECKING, Unionfrom uuid import UUIDimport grapheneimport requestsfrom django.core.exceptions import ValidationError-from django.core.files.uploadedfile import SimpleUploadedFilefrom graphene import ObjectTypefrom graphql.error import GraphQLErrorfrom PIL import Image@@ -18,7 +16,6 @@ from ....core.utils import generate_unique_slugfrom ....plugins.webhook.utils import APP_ID_PREFIXif TYPE_CHECKING:- # flake8: noqafrom django.db.models import Modeldiff --git a/saleor/graphql/product/bulk_mutations/products.py b/saleor/graphql/product/bulk_mutations/products.pyindex 19992927e2..587d0c0a1c 100644--- a/saleor/graphql/product/bulk_mutations/products.py+++ b/saleor/graphql/product/bulk_mutations/products.py@@ -375,7 +375,7 @@ class ProductVariantBulkCreate(BaseMutation):))for channel_listing_data in channels_data:- if not channel_listing_data["channel"].id in channels_assigned_to_product:+ if channel_listing_data["channel"].id not in channels_assigned_to_product:channels_not_assigned_to_product.append(channel_listing_data["channel_id"])diff --git a/saleor/graphql/product/mutations/__init__.py b/saleor/graphql/product/mutations/__init__.pyindex a29d6fefbc..5f68c9a430 100644--- a/saleor/graphql/product/mutations/__init__.py+++ b/saleor/graphql/product/mutations/__init__.py@@ -1,7 +1,5 @@-# flake8: noqa: F401-from .product_type_create import ProductTypeCreatefrom .product_type_delete import ProductTypeDeletefrom .product_type_update import ProductTypeUpdate-__all__ = ["ProductTypeCreate" "ProductTypeUpdate" "ProductTypeDelete"]+__all__ = ["ProductTypeCreate", "ProductTypeUpdate", "ProductTypeDelete"]diff --git a/saleor/graphql/product/types/__init__.py b/saleor/graphql/product/types/__init__.pyindex 4249bece4d..9dc83b1f0a 100644--- a/saleor/graphql/product/types/__init__.py+++ b/saleor/graphql/product/types/__init__.py@@ -1,4 +1,3 @@-# flake8: noqafrom .digital_contents import (DigitalContent,DigitalContentCountableConnection,@@ -17,3 +16,20 @@ from .products import (ProductVariant,ProductVariantCountableConnection,)++__all__ = [+ "Category",+ "CategoryCountableConnection",+ "Collection",+ "CollectionCountableConnection",+ "Product",+ "ProductCountableConnection",+ "ProductMedia",+ "ProductType",+ "ProductTypeCountableConnection",+ "ProductVariant",+ "ProductVariantCountableConnection",+ "DigitalContent",+ "DigitalContentCountableConnection",+ "DigitalContentUrl",+]diff --git a/saleor/graphql/tax/mutations/__init__.py b/saleor/graphql/tax/mutations/__init__.pyindex 18003473b9..792f96cce1 100644--- a/saleor/graphql/tax/mutations/__init__.py+++ b/saleor/graphql/tax/mutations/__init__.py@@ -1,5 +1,3 @@-# flake8: noqa: F401-from .tax_exemption_manage import TaxExemptionManage__all__ = ["TaxExemptionManage"]diff --git a/saleor/order/migrations/0001_initial.py b/saleor/order/migrations/0001_initial.pyindex 10150b0a24..d0f75eca71 100644--- a/saleor/order/migrations/0001_initial.py+++ b/saleor/order/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsimport django.core.validatorsdiff --git a/saleor/order/migrations/0002_auto_20150820_1955.py b/saleor/order/migrations/0002_auto_20150820_1955.pyindex d9029d4931..48a738d70c 100644--- a/saleor/order/migrations/0002_auto_20150820_1955.py+++ b/saleor/order/migrations/0002_auto_20150820_1955.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/order/migrations/0003_auto_20150825_1433.py b/saleor/order/migrations/0003_auto_20150825_1433.pyindex eb88f6f754..3d2367c817 100644--- a/saleor/order/migrations/0003_auto_20150825_1433.py+++ b/saleor/order/migrations/0003_auto_20150825_1433.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0004_order_total.py b/saleor/order/migrations/0004_order_total.pyindex 658aeb1e82..eda6fcc753 100644--- a/saleor/order/migrations/0004_order_total.py+++ b/saleor/order/migrations/0004_order_total.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0005_deliverygroup_last_updated.py b/saleor/order/migrations/0005_deliverygroup_last_updated.pyindex 8eca9a7d9d..8e950f4a51 100644--- a/saleor/order/migrations/0005_deliverygroup_last_updated.py+++ b/saleor/order/migrations/0005_deliverygroup_last_updated.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0006_deliverygroup_shipping_method.py b/saleor/order/migrations/0006_deliverygroup_shipping_method.pyindex 4931ca01e8..9651e32034 100644--- a/saleor/order/migrations/0006_deliverygroup_shipping_method.py+++ b/saleor/order/migrations/0006_deliverygroup_shipping_method.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0007_deliverygroup_tracking_number.py b/saleor/order/migrations/0007_deliverygroup_tracking_number.pyindex 0bd813a3b4..316e4d197f 100644--- a/saleor/order/migrations/0007_deliverygroup_tracking_number.py+++ b/saleor/order/migrations/0007_deliverygroup_tracking_number.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0008_auto_20151026_0820.py b/saleor/order/migrations/0008_auto_20151026_0820.pyindex 622ed252d8..b34028c722 100644--- a/saleor/order/migrations/0008_auto_20151026_0820.py+++ b/saleor/order/migrations/0008_auto_20151026_0820.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsimport django.db.models.deletiondiff --git a/saleor/order/migrations/0009_auto_20151201_0820.py b/saleor/order/migrations/0009_auto_20151201_0820.pyindex f0e32cbdec..2eb45b9e5d 100644--- a/saleor/order/migrations/0009_auto_20151201_0820.py+++ b/saleor/order/migrations/0009_auto_20151201_0820.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0010_auto_20160119_0541.py b/saleor/order/migrations/0010_auto_20160119_0541.pyindex de8bef3095..06e2bf5038 100644--- a/saleor/order/migrations/0010_auto_20160119_0541.py+++ b/saleor/order/migrations/0010_auto_20160119_0541.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-19 11:41from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0011_auto_20160207_0534.py b/saleor/order/migrations/0011_auto_20160207_0534.pyindex 7bf65eacdd..bc1c00fd16 100644--- a/saleor/order/migrations/0011_auto_20160207_0534.py+++ b/saleor/order/migrations/0011_auto_20160207_0534.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-02-07 11:34from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0012_auto_20160216_1032.py b/saleor/order/migrations/0012_auto_20160216_1032.pyindex 0a4e41fa8d..b433314096 100644--- a/saleor/order/migrations/0012_auto_20160216_1032.py+++ b/saleor/order/migrations/0012_auto_20160216_1032.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-02-16 16:32from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0013_auto_20160906_0741.py b/saleor/order/migrations/0013_auto_20160906_0741.pyindex 0fef233470..ec56c7746d 100644--- a/saleor/order/migrations/0013_auto_20160906_0741.py+++ b/saleor/order/migrations/0013_auto_20160906_0741.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-09-06 12:41from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0014_auto_20161028_0955.py b/saleor/order/migrations/0014_auto_20161028_0955.pyindex 8a82547a88..0e3f21bedb 100644--- a/saleor/order/migrations/0014_auto_20161028_0955.py+++ b/saleor/order/migrations/0014_auto_20161028_0955.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-10-28 14:55from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0015_auto_20170206_0407.py b/saleor/order/migrations/0015_auto_20170206_0407.pyindex 43b878ffbd..07964efc2c 100644--- a/saleor/order/migrations/0015_auto_20170206_0407.py+++ b/saleor/order/migrations/0015_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0016_order_language_code.py b/saleor/order/migrations/0016_order_language_code.pyindex 82e49b1fea..d12c14269b 100644--- a/saleor/order/migrations/0016_order_language_code.py+++ b/saleor/order/migrations/0016_order_language_code.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-14 16:24from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0017_auto_20170906_0556.py b/saleor/order/migrations/0017_auto_20170906_0556.pyindex 607aef7881..d8fcc34c79 100644--- a/saleor/order/migrations/0017_auto_20170906_0556.py+++ b/saleor/order/migrations/0017_auto_20170906_0556.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-06 10:56from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0018_auto_20170919_0839.py b/saleor/order/migrations/0018_auto_20170919_0839.pyindex 24ed820061..f73d9a0f95 100644--- a/saleor/order/migrations/0018_auto_20170919_0839.py+++ b/saleor/order/migrations/0018_auto_20170919_0839.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-19 13:39from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0019_auto_20171109_1423.py b/saleor/order/migrations/0019_auto_20171109_1423.pyindex 0c2b31785a..274fc0d34f 100644--- a/saleor/order/migrations/0019_auto_20171109_1423.py+++ b/saleor/order/migrations/0019_auto_20171109_1423.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-09 20:23from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0020_auto_20171123_0609.py b/saleor/order/migrations/0020_auto_20171123_0609.pyindex ad78ca5696..4f03c6bdc7 100644--- a/saleor/order/migrations/0020_auto_20171123_0609.py+++ b/saleor/order/migrations/0020_auto_20171123_0609.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-23 12:09from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0021_auto_20171129_1004.py b/saleor/order/migrations/0021_auto_20171129_1004.pyindex 971e9f3abe..e709c7b6a5 100644--- a/saleor/order/migrations/0021_auto_20171129_1004.py+++ b/saleor/order/migrations/0021_auto_20171129_1004.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0022_auto_20171205_0428.py b/saleor/order/migrations/0022_auto_20171205_0428.pyindex 4786948cc1..966b2ba99e 100644--- a/saleor/order/migrations/0022_auto_20171205_0428.py+++ b/saleor/order/migrations/0022_auto_20171205_0428.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-05 10:28from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0023_auto_20171206_0506.py b/saleor/order/migrations/0023_auto_20171206_0506.pyindex 376a1f393d..0aad78b769 100644--- a/saleor/order/migrations/0023_auto_20171206_0506.py+++ b/saleor/order/migrations/0023_auto_20171206_0506.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-06 11:06from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0024_remove_order_status.py b/saleor/order/migrations/0024_remove_order_status.pyindex 4ca5edbb9b..b41dd8a822 100644--- a/saleor/order/migrations/0024_remove_order_status.py+++ b/saleor/order/migrations/0024_remove_order_status.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-14 11:06-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/order/migrations/0025_auto_20171214_1015.py b/saleor/order/migrations/0025_auto_20171214_1015.pyindex 6baecc96ff..6f89deedb9 100644--- a/saleor/order/migrations/0025_auto_20171214_1015.py+++ b/saleor/order/migrations/0025_auto_20171214_1015.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-14 16:15-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0026_auto_20171218_0428.py b/saleor/order/migrations/0026_auto_20171218_0428.pyindex 73d98fb2e0..0e5ad3d216 100644--- a/saleor/order/migrations/0026_auto_20171218_0428.py+++ b/saleor/order/migrations/0026_auto_20171218_0428.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-18 10:28-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0027_auto_20180108_0814.py b/saleor/order/migrations/0027_auto_20180108_0814.pyindex e42f21498c..feca262aa5 100644--- a/saleor/order/migrations/0027_auto_20180108_0814.py+++ b/saleor/order/migrations/0027_auto_20180108_0814.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14-from __future__ import unicode_literalsimport django.core.validatorsimport django.db.models.deletiondiff --git a/saleor/order/migrations/0028_status_fsm.py b/saleor/order/migrations/0028_status_fsm.pyindex 7454132add..1b78338e33 100644--- a/saleor/order/migrations/0028_status_fsm.py+++ b/saleor/order/migrations/0028_status_fsm.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-03 13:08-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0029_auto_20180111_0845.py b/saleor/order/migrations/0029_auto_20180111_0845.pyindex f34dd2ffc2..8b8ddbd220 100644--- a/saleor/order/migrations/0029_auto_20180111_0845.py+++ b/saleor/order/migrations/0029_auto_20180111_0845.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-11 14:45-from __future__ import unicode_literalsimport django.db.models.deletionfrom django.conf import settingsdiff --git a/saleor/order/migrations/0030_auto_20180118_0605.py b/saleor/order/migrations/0030_auto_20180118_0605.pyindex e29fbbb2b1..ce2eac44d9 100644--- a/saleor/order/migrations/0030_auto_20180118_0605.py+++ b/saleor/order/migrations/0030_auto_20180118_0605.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-18 12:05-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0031_auto_20180119_0405.py b/saleor/order/migrations/0031_auto_20180119_0405.pyindex 784b18b9af..e45a0faedd 100644--- a/saleor/order/migrations/0031_auto_20180119_0405.py+++ b/saleor/order/migrations/0031_auto_20180119_0405.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-19 10:05from __future__ import unicode_literalsdiff --git a/saleor/order/migrations/0032_orderline_is_shipping_required.py b/saleor/order/migrations/0032_orderline_is_shipping_required.pyindex dea376efec..369b53cbe5 100644--- a/saleor/order/migrations/0032_orderline_is_shipping_required.py+++ b/saleor/order/migrations/0032_orderline_is_shipping_required.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-23 14:28-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/migrations/0033_auto_20180123_0832.py b/saleor/order/migrations/0033_auto_20180123_0832.pyindex 710a6ce4e7..b2def0e6d6 100644--- a/saleor/order/migrations/0033_auto_20180123_0832.py+++ b/saleor/order/migrations/0033_auto_20180123_0832.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-23 14:32-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/order/tests/test_notifications.py b/saleor/order/tests/test_notifications.pyindex 26a55e3dbb..8f246971a2 100644--- a/saleor/order/tests/test_notifications.py+++ b/saleor/order/tests/test_notifications.py@@ -286,9 +286,13 @@ def test_get_default_fulfillment_payload(fulfillment, digital_content, site_settpayload = get_default_fulfillment_payload(order, fulfillment)# make sure that test will not fail because of the list order- payload["order"]["lines"] = sorted(payload["order"]["lines"], key=lambda l: l["id"])- payload["physical_lines"] = sorted(payload["physical_lines"], key=lambda l: l["id"])- order_payload["lines"] = sorted(order_payload["lines"], key=lambda l: l["id"])+ payload["order"]["lines"] = sorted(+ payload["order"]["lines"], key=lambda line: line["id"]+ )+ payload["physical_lines"] = sorted(+ payload["physical_lines"], key=lambda line: line["id"]+ )+ order_payload["lines"] = sorted(order_payload["lines"], key=lambda line: line["id"])digital_line = fulfillment.lines.get(order_line=line.id)physical_line = fulfillment.lines.exclude(id=digital_line.id).first()diff --git a/saleor/payment/gateway.py b/saleor/payment/gateway.pyindex 400272bc82..28f24ace33 100644--- a/saleor/payment/gateway.py+++ b/saleor/payment/gateway.py@@ -1,6 +1,6 @@import loggingfrom decimal import Decimal-from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union+from typing import TYPE_CHECKING, Callable, List, Optionalfrom ..account.models import Userfrom ..app.models import App@@ -31,7 +31,6 @@ from .utils import ()if TYPE_CHECKING:- # flake8: noqafrom ..plugins.manager import PluginsManagerUserType = Optional[User]diff --git a/saleor/payment/gateways/authorize_net/plugin.py b/saleor/payment/gateways/authorize_net/plugin.pyindex f536754071..51689757e2 100644--- a/saleor/payment/gateways/authorize_net/plugin.py+++ b/saleor/payment/gateways/authorize_net/plugin.py@@ -23,7 +23,6 @@ from . import (GATEWAY_NAME = "Authorize.Net"if TYPE_CHECKING:- # flake8: noqafrom ...interface import CustomerSourcefrom ..models import PluginConfigurationfrom . import GatewayResponse, PaymentData@@ -62,7 +61,9 @@ class AuthorizeNetGatewayPlugin(BasePlugin):},"use_sandbox": {"type": ConfigurationTypeField.BOOLEAN,- "help_text": "Determines if Saleor should use Authorize.Net sandbox environment.",+ "help_text": (+ "Determines if Saleor should use Authorize.Net sandbox environment."+ ),"label": "Use sandbox",},"store_customers_card": {diff --git a/saleor/payment/gateways/braintree/plugin.py b/saleor/payment/gateways/braintree/plugin.pyindex c868719132..924c14f42c 100644--- a/saleor/payment/gateways/braintree/plugin.py+++ b/saleor/payment/gateways/braintree/plugin.py@@ -17,7 +17,6 @@ from . import (GATEWAY_NAME = "Braintree"if TYPE_CHECKING:- # flake8: noqafrom ...interface import CustomerSourcefrom . import GatewayResponse, PaymentData, TokenConfig@@ -78,7 +77,9 @@ class BraintreeGatewayPlugin(BasePlugin):},"Require 3D secure": {"type": ConfigurationTypeField.BOOLEAN,- "help_text": "Determines if Saleor should enforce 3D Secure during payment.",+ "help_text": (+ "Determines if Saleor should enforce 3D Secure during payment."+ ),"label": "Require 3D Secure",},"Supported currencies": {diff --git a/saleor/payment/gateways/np_atobarai/plugin.py b/saleor/payment/gateways/np_atobarai/plugin.pyindex 62bd5a05cb..459081f35c 100644--- a/saleor/payment/gateways/np_atobarai/plugin.py+++ b/saleor/payment/gateways/np_atobarai/plugin.py@@ -27,7 +27,6 @@ GATEWAY_NAME = "NP後払い"REQUIRED_FIELDS = (MERCHANT_CODE, SP_CODE, TERMINAL_ID, SHIPPING_COMPANY)if TYPE_CHECKING:- # flake8: noqafrom ....plugins.models import PluginConfigurationfrom . import GatewayResponse, PaymentData@@ -192,7 +191,7 @@ class NPAtobaraiGatewayPlugin(BasePlugin):raise ValidationError({field: ValidationError(- f"The parameter is required.",+ "The parameter is required.",code=PluginErrorCode.REQUIRED.value,)for field in missing_fields@@ -202,7 +201,7 @@ class NPAtobaraiGatewayPlugin(BasePlugin):raise ValidationError({SHIPPING_COMPANY: ValidationError(- f"Shipping company code is invalid",+ "Shipping company code is invalid",code=PluginErrorCode.INVALID.value,)}diff --git a/saleor/payment/gateways/razorpay/__init__.py b/saleor/payment/gateways/razorpay/__init__.pyindex 6b5ef58e40..f5fc6dc190 100644--- a/saleor/payment/gateways/razorpay/__init__.py+++ b/saleor/payment/gateways/razorpay/__init__.py@@ -64,7 +64,7 @@ def get_error_message_from_razorpay_error(exc: BaseException):def clean_razorpay_response(response: Dict):- """Convert the Razorpay response to our internal representation for easier processing.+ """Convert the Razorpay response to our internal representation.As the Razorpay response payload contains the final amountin paisa, we convert the amount to Indian Rupees (by dividing by 100).diff --git a/saleor/payment/gateways/stripe/deprecated/plugin.py b/saleor/payment/gateways/stripe/deprecated/plugin.pyindex 4b6bdf2605..849459635a 100644--- a/saleor/payment/gateways/stripe/deprecated/plugin.py+++ b/saleor/payment/gateways/stripe/deprecated/plugin.py@@ -16,7 +16,6 @@ from . import (GATEWAY_NAME = "Stripe (Deprecated)"if TYPE_CHECKING:- # flake8: noqafrom ....interface import CustomerSourcefrom . import GatewayResponse, PaymentDatadiff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.pyindex d822606d4e..8df43a4d3a 100644--- a/saleor/payment/gateways/stripe/plugin.py+++ b/saleor/payment/gateways/stripe/plugin.py@@ -37,7 +37,6 @@ from .stripe_api import (from .webhooks import handle_webhookif TYPE_CHECKING:- # flake8: noqafrom ....plugins.models import PluginConfigurationfrom .consts import (diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.pyindex 5f5ab9b9b9..1972dd46a1 100644--- a/saleor/plugins/avatax/plugin.py+++ b/saleor/plugins/avatax/plugin.py@@ -1,12 +1,11 @@import loggingfrom dataclasses import asdictfrom decimal import Decimal-from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Union+from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Unionfrom urllib.parse import urljoinimport opentracingimport opentracing.tags-from django.contrib.sites.models import Sitefrom django.core.exceptions import ValidationErrorfrom django.utils.functional import SimpleLazyObjectfrom django_countries import countries@@ -16,7 +15,6 @@ from ...checkout import base_calculationsfrom ...checkout.fetch import fetch_checkout_linesfrom ...core.taxes import TaxError, TaxType, charge_taxes_on_shipping, zero_taxed_moneyfrom ...discount import DiscountInfo-from ...order import base_calculations as base_order_calculationsfrom ...order.interface import OrderTaxedPricesDatafrom ...product.models import ProductTypefrom ..base_plugin import BasePlugin, ConfigurationTypeField@@ -43,11 +41,8 @@ from . import (from .tasks import api_post_request_taskif TYPE_CHECKING:- # flake8: noqafrom ...account.models import Address- from ...channel.models import Channelfrom ...checkout.fetch import CheckoutInfo, CheckoutLineInfo- from ...checkout.models import Checkout, CheckoutLinefrom ...order.models import Order, OrderLinefrom ...product.models import Product, ProductVariantfrom ..models import PluginConfigurationdiff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.pyindex 7b7deb9ffc..b15a917574 100644--- a/saleor/plugins/base_plugin.py+++ b/saleor/plugins/base_plugin.py@@ -36,7 +36,6 @@ from ..payment.interface import (from .models import PluginConfigurationif TYPE_CHECKING:- # flake8: noqafrom ..account.models import Address, Group, Userfrom ..app.models import Appfrom ..attribute.models import Attribute, AttributeValue@@ -46,8 +45,8 @@ if TYPE_CHECKING:from ..core.middleware import Requestorfrom ..core.notify_events import NotifyEventTypefrom ..core.taxes import TaxData, TaxType- from ..discount import DiscountInfo, Voucher- from ..discount.models import Sale+ from ..discount import DiscountInfo+ from ..discount.models import Sale, Voucherfrom ..giftcard.models import GiftCardfrom ..invoice.models import Invoicefrom ..menu.models import Menu, MenuItem@@ -66,7 +65,6 @@ if TYPE_CHECKING:from ..warehouse.models import WarehousePluginConfigurationType = List[dict]-NoneType = type(None)RequestorOrLazyObject = Union[SimpleLazyObject, "Requestor"]@@ -145,381 +143,379 @@ class BasePlugin:def __str__(self):return self.PLUGIN_NAME- # Trigger when address is created.+ # Trigger when address is created.#- # Overwrite this method if you need to trigger specific logic after an address is- # created.+ # Overwrite this method if you need to trigger specific logic after an address is+ # created.address_created: Callable[["Address", None], None]- # Trigger when address is deleted.+ # Trigger when address is deleted.#- # Overwrite this method if you need to trigger specific logic after an address is- # deleted.+ # Overwrite this method if you need to trigger specific logic after an address is+ # deleted.address_deleted: Callable[["Address", None], None]- # Trigger when address is updated.+ # Trigger when address is updated.#- # Overwrite this method if you need to trigger specific logic after an address is- # updated.+ # Overwrite this method if you need to trigger specific logic after an address is+ # updated.address_updated: Callable[["Address", None], None]- # Trigger when app is installed.+ # Trigger when app is installed.#- # Overwrite this method if you need to trigger specific logic after an app is- # installed.+ # Overwrite this method if you need to trigger specific logic after an app is+ # installed.app_installed: Callable[["App", None], None]- # Trigger when app is deleted.+ # Trigger when app is deleted.#- # Overwrite this method if you need to trigger specific logic after an app is- # deleted.+ # Overwrite this method if you need to trigger specific logic after an app is+ # deleted.app_deleted: Callable[["App", None], None]- # Trigger when app is updated.+ # Trigger when app is updated.#- # Overwrite this method if you need to trigger specific logic after an app is- # updated.+ # Overwrite this method if you need to trigger specific logic after an app is+ # updated.app_updated: Callable[["App", None], None]- # Trigger when channel status is changed.+ # Trigger when channel status is changed.#- # Overwrite this method if you need to trigger specific logic after an app- # status is changed.+ # Overwrite this method if you need to trigger specific logic after an app+ # status is changed.app_status_changed: Callable[["App", None], None]- # Apply taxes to the product price based on the customer country.+ # Apply taxes to the product price based on the customer country.#- # Overwrite this method if you want to show products with taxes.+ # Overwrite this method if you want to show products with taxes.apply_taxes_to_product: Callable[["Product", Money, Country, TaxedMoney], TaxedMoney]- # Assign tax code dedicated to plugin.+ # Assign tax code dedicated to plugin.assign_tax_code_to_object_meta: Callable[- [Union["Product", "ProductType"], Union[str, NoneType], Any], Any+ [Union["Product", "ProductType"], Union[str, None], Any], Any]- # Trigger when attribute is created.+ # Trigger when attribute is created.#- # Overwrite this method if you need to trigger specific logic after an attribute is- # installed.+ # Overwrite this method if you need to trigger specific logic after an attribute is+ # installed.attribute_created: Callable[["Attribute", None], None]- # Trigger when attribute is deleted.+ # Trigger when attribute is deleted.#- # Overwrite this method if you need to trigger specific logic after an attribute is- # deleted.+ # Overwrite this method if you need to trigger specific logic after an attribute is+ # deleted.attribute_deleted: Callable[["Attribute", None], None]- # Trigger when attribute is updated.+ # Trigger when attribute is updated.#- # Overwrite this method if you need to trigger specific logic after an attribute is- # updated.+ # Overwrite this method if you need to trigger specific logic after an attribute is+ # updated.attribute_updated: Callable[["Attribute", None], None]- # Trigger when attribute value is created.+ # Trigger when attribute value is created.#- # Overwrite this method if you need to trigger specific logic after an attribute- # value is installed.+ # Overwrite this method if you need to trigger specific logic after an attribute+ # value is installed.attribute_value_created: Callable[["AttributeValue", None], None]- # Trigger when attribute value is deleted.+ # Trigger when attribute value is deleted.#- # Overwrite this method if you need to trigger specific logic after an attribute- # value is deleted.+ # Overwrite this method if you need to trigger specific logic after an attribute+ # value is deleted.attribute_value_deleted: Callable[["AttributeValue", None], None]- # Trigger when attribute value is updated.+ # Trigger when attribute value is updated.#- # Overwrite this method if you need to trigger specific logic after an attribute- # value is updated.+ # Overwrite this method if you need to trigger specific logic after an attribute+ # value is updated.attribute_value_updated: Callable[["AttributeValue", None], None]- # Authenticate user which should be assigned to the request.+ # Authenticate user which should be assigned to the request.#- # Overwrite this method if the plugin handles authentication flow.- authenticate_user: Callable[- [WSGIRequest, Optional["User"]], Union["User", NoneType]- ]+ # Overwrite this method if the plugin handles authentication flow.+ authenticate_user: Callable[[WSGIRequest, Optional["User"]], Union["User", None]]authorize_payment: Callable[["PaymentData", Any], GatewayResponse]- # Update order lines taxes.+ # Update order lines taxes.#- # Overwrite this method if you need to apply specific logic for applying taxes on- # order lines. Return Iterable["OrderLine"].+ # Overwrite this method if you need to apply specific logic for applying taxes on+ # order lines. Return Iterable["OrderLine"].update_taxes_for_order_lines: Callable[["Order", List["OrderLine"], List["OrderLine"]], List["OrderLine"]]- # Calculate checkout line total.+ # Calculate checkout line total.#- # Overwrite this method if you need to apply specific logic for the calculation- # of a checkout line total. Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of a checkout line total. Return TaxedMoney.calculate_checkout_line_total: Callable[["CheckoutInfo",List["CheckoutLineInfo"],"CheckoutLineInfo",- Union["Address", NoneType],+ Union["Address", None],Iterable["DiscountInfo"],TaxedMoney,],TaxedMoney,]- # Calculate checkout line unit price.+ # Calculate checkout line unit price.calculate_checkout_line_unit_price: Callable[["CheckoutInfo",List["CheckoutLineInfo"],"CheckoutLineInfo",- Union["Address", NoneType],+ Union["Address", None],Iterable["DiscountInfo"],Any,],TaxedMoney,]- # Calculate the shipping costs for checkout.+ # Calculate the shipping costs for checkout.#- # Overwrite this method if you need to apply specific logic for the calculation- # of shipping costs. Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of shipping costs. Return TaxedMoney.calculate_checkout_shipping: Callable[["CheckoutInfo",List["CheckoutLineInfo"],- Union["Address", NoneType],+ Union["Address", None],List["DiscountInfo"],TaxedMoney,],TaxedMoney,]- # Calculate the total for checkout.+ # Calculate the total for checkout.#- # Overwrite this method if you need to apply specific logic for the calculation- # of a checkout total. Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of a checkout total. Return TaxedMoney.calculate_checkout_total: Callable[["CheckoutInfo",List["CheckoutLineInfo"],- Union["Address", NoneType],+ Union["Address", None],List["DiscountInfo"],TaxedMoney,],TaxedMoney,]- # Calculate order line total.+ # Calculate order line total.#- # Overwrite this method if you need to apply specific logic for the calculation- # of a order line total. Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of a order line total. Return TaxedMoney.calculate_order_line_total: Callable[["Order", "OrderLine", "ProductVariant", "Product", TaxedMoney], TaxedMoney]- # Calculate order line unit price.+ # Calculate order line unit price.#- # Update order line unit price in the order in case of changes in draft order.- # Return TaxedMoney.- # Overwrite this method if you need to apply specific logic for the calculation- # of an order line unit price.+ # Update order line unit price in the order in case of changes in draft order.+ # Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of an order line unit price.calculate_order_line_unit: Callable[["Order", "OrderLine", "ProductVariant", "Product", TaxedMoney], TaxedMoney]- # Calculate the shipping costs for the order.+ # Calculate the shipping costs for the order.#- # Update shipping costs in the order in case of changes in shipping address or- # changes in draft order. Return TaxedMoney.+ # Update shipping costs in the order in case of changes in shipping address or+ # changes in draft order. Return TaxedMoney.calculate_order_shipping: Callable[["Order", TaxedMoney], TaxedMoney]- # Calculate order total.+ # Calculate order total.#- # Overwrite this method if you need to apply specific logic for the calculation- # of a order total. Return TaxedMoney.+ # Overwrite this method if you need to apply specific logic for the calculation+ # of a order total. Return TaxedMoney.calculate_order_total: Callable[["Order", List["OrderLine"], TaxedMoney], TaxedMoney]capture_payment: Callable[["PaymentData", Any], GatewayResponse]- # Trigger when category is created.+ # Trigger when category is created.#- # Overwrite this method if you need to trigger specific logic after a category is- # created.+ # Overwrite this method if you need to trigger specific logic after a category is+ # created.category_created: Callable[["Category", None], None]- # Trigger when category is deleted.+ # Trigger when category is deleted.#- # Overwrite this method if you need to trigger specific logic after a category is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a category is+ # deleted.category_deleted: Callable[["Category", None], None]- # Trigger when category is updated.+ # Trigger when category is updated.#- # Overwrite this method if you need to trigger specific logic after a category is- # updated.+ # Overwrite this method if you need to trigger specific logic after a category is+ # updated.category_updated: Callable[["Category", None], None]- # Trigger when channel is created.+ # Trigger when channel is created.#- # Overwrite this method if you need to trigger specific logic after a channel is- # created.+ # Overwrite this method if you need to trigger specific logic after a channel is+ # created.channel_created: Callable[["Channel", None], None]- # Trigger when channel is deleted.+ # Trigger when channel is deleted.#- # Overwrite this method if you need to trigger specific logic after a channel is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a channel is+ # deleted.channel_deleted: Callable[["Channel", None], None]- # Trigger when channel is updated.+ # Trigger when channel is updated.#- # Overwrite this method if you need to trigger specific logic after a channel is- # updated.+ # Overwrite this method if you need to trigger specific logic after a channel is+ # updated.channel_updated: Callable[["Channel", None], None]- # Trigger when channel status is changed.+ # Trigger when channel status is changed.#- # Overwrite this method if you need to trigger specific logic after a channel- # status is changed.+ # Overwrite this method if you need to trigger specific logic after a channel+ # status is changed.channel_status_changed: Callable[["Channel", None], None]change_user_address: Callable[- ["Address", Union[str, NoneType], Union["User", NoneType], "Address"], "Address"+ ["Address", Union[str, None], Union["User", None], "Address"], "Address"]- # Retrieves the balance remaining on a shopper's gift card+ # Retrieves the balance remaining on a shopper's gift cardcheck_payment_balance: Callable[[dict, str], dict]- # Trigger when checkout is created.+ # Trigger when checkout is created.#- # Overwrite this method if you need to trigger specific logic when a checkout is- # created.+ # Overwrite this method if you need to trigger specific logic when a checkout is+ # created.checkout_created: Callable[["Checkout", Any], Any]- # Trigger when checkout is updated.+ # Trigger when checkout is updated.#- # Overwrite this method if you need to trigger specific logic when a checkout is- # updated.+ # Overwrite this method if you need to trigger specific logic when a checkout is+ # updated.checkout_updated: Callable[["Checkout", Any], Any]- # Trigger when checkout metadata is updated.+ # Trigger when checkout metadata is updated.#- # Overwrite this method if you need to trigger specific logic when a checkout- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic when a checkout+ # metadata is updated.checkout_metadata_updated: Callable[["Checkout", Any], Any]- # Trigger when collection is created.+ # Trigger when collection is created.#- # Overwrite this method if you need to trigger specific logic after a collection is- # created.+ # Overwrite this method if you need to trigger specific logic after a collection is+ # created.collection_created: Callable[["Collection", Any], Any]- # Trigger when collection is deleted.+ # Trigger when collection is deleted.#- # Overwrite this method if you need to trigger specific logic after a collection is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a collection is+ # deleted.collection_deleted: Callable[["Collection", Any], Any]- # Trigger when collection is updated.+ # Trigger when collection is updated.#- # Overwrite this method if you need to trigger specific logic after a collection is- # updated.+ # Overwrite this method if you need to trigger specific logic after a collection is+ # updated.collection_updated: Callable[["Collection", Any], Any]- # Trigger when collection metadata is updated.+ # Trigger when collection metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a collection- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a collection+ # metadata is updated.collection_metadata_updated: Callable[["Collection", Any], Any]confirm_payment: Callable[["PaymentData", Any], GatewayResponse]- # Trigger when user is created.+ # Trigger when user is created.#- # Overwrite this method if you need to trigger specific logic after a user is- # created.+ # Overwrite this method if you need to trigger specific logic after a user is+ # created.customer_created: Callable[["User", Any], Any]- # Trigger when user is deleted.+ # Trigger when user is deleted.#- # Overwrite this method if you need to trigger specific logic after a user is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a user is+ # deleted.customer_deleted: Callable[["User", Any], Any]- # Trigger when user is updated.+ # Trigger when user is updated.#- # Overwrite this method if you need to trigger specific logic after a user is- # updated.+ # Overwrite this method if you need to trigger specific logic after a user is+ # updated.customer_updated: Callable[["User", Any], Any]- # Trigger when user metadata is updated.+ # Trigger when user metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a user- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a user+ # metadata is updated.customer_metadata_updated: Callable[["User", Any], Any]- # Handle authentication request.+ # Handle authentication request.#- # Overwrite this method if the plugin handles authentication flow.+ # Overwrite this method if the plugin handles authentication flow.external_authentication_url: Callable[[dict, WSGIRequest, dict], dict]- # Handle logout request.+ # Handle logout request.#- # Overwrite this method if the plugin handles logout flow.+ # Overwrite this method if the plugin handles logout flow.external_logout: Callable[[dict, WSGIRequest, dict], Any]- # Handle authentication request responsible for obtaining access tokens.+ # Handle authentication request responsible for obtaining access tokens.#- # Overwrite this method if the plugin handles authentication flow.+ # Overwrite this method if the plugin handles authentication flow.external_obtain_access_tokens: Callable[[dict, WSGIRequest, ExternalAccessTokens], ExternalAccessTokens]- # Handle authentication refresh request.+ # Handle authentication refresh request.#- # Overwrite this method if the plugin handles authentication flow and supports- # refreshing the access.+ # Overwrite this method if the plugin handles authentication flow and supports+ # refreshing the access.external_refresh: Callable[[dict, WSGIRequest, ExternalAccessTokens], ExternalAccessTokens]- # Verify the provided authentication data.+ # Verify the provided authentication data.#- # Overwrite this method if the plugin should validate the authentication data.+ # Overwrite this method if the plugin should validate the authentication data.external_verify: Callable[- [dict, WSGIRequest, Tuple[Union["User", NoneType], dict]],- Tuple[Union["User", NoneType], dict],+ [dict, WSGIRequest, Tuple[Union["User", None], dict]],+ Tuple[Union["User", None], dict],]- # Triggered when ShopFetchTaxRates mutation is called.+ # Triggered when ShopFetchTaxRates mutation is called.fetch_taxes_data: Callable[[Any], Any]- # Trigger when fulfillment is created.+ # Trigger when fulfillment is created.#- # Overwrite this method if you need to trigger specific logic when a fulfillment is- # created.+ # Overwrite this method if you need to trigger specific logic when a fulfillment is+ # created.fulfillment_created: Callable[["Fulfillment", Any], Any]- # Trigger when fulfillment is cancelled.+ # Trigger when fulfillment is cancelled.#- # Overwrite this method if you need to trigger specific logic when a fulfillment is- # cancelled.+ # Overwrite this method if you need to trigger specific logic when a fulfillment is+ # cancelled.fulfillment_canceled: Callable[["Fulfillment", Any], Any]- # Trigger when fulfillment is approved.+ # Trigger when fulfillment is approved.#- # Overwrite this method if you need to trigger specific logic when a fulfillment is- # approved.+ # Overwrite this method if you need to trigger specific logic when a fulfillment is+ # approved.fulfillment_approved: Callable[["Fulfillment", Any], Any]- # Trigger when fulfillment metadata is updated.+ # Trigger when fulfillment metadata is updated.#- # Overwrite this method if you need to trigger specific logic when a fulfillment- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic when a fulfillment+ # metadata is updated.fulfillment_metadata_updated: Callable[["Fulfillment", Any], Any]get_checkout_line_tax_rate: Callable[@@ -527,7 +523,7 @@ class BasePlugin:"CheckoutInfo",List["CheckoutLineInfo"],"CheckoutLineInfo",- Union["Address", NoneType],+ Union["Address", None],Iterable["DiscountInfo"],Decimal,],@@ -538,7 +534,7 @@ class BasePlugin:["CheckoutInfo",Iterable["CheckoutLineInfo"],- Union["Address", NoneType],+ Union["Address", None],Iterable["DiscountInfo"],Any,],@@ -555,7 +551,7 @@ class BasePlugin:get_client_token: Callable[[Any, Any], Any]get_order_line_tax_rate: Callable[- ["Order", "Product", "ProductVariant", Union["Address", NoneType], Decimal],+ ["Order", "Product", "ProductVariant", Union["Address", None], Decimal],Decimal,]@@ -568,222 +564,222 @@ class BasePlugin:get_supported_currencies: Callable[[Any], Any]- # Return tax code from object meta.+ # Return tax code from object meta.get_tax_code_from_object_meta: Callable[[Union["Product", "ProductType"], "TaxType"], "TaxType"]- # Return tax rate percentage value for a given tax rate type in a country.+ # Return tax rate percentage value for a given tax rate type in a country.#- # It is used only by the old storefront.+ # It is used only by the old storefront.get_tax_rate_percentage_value: Callable[[Union["Product", "ProductType"], Country, Any], Decimal]- # Return list of all tax categories.+ # Return list of all tax categories.#- # The returned list will be used to provide staff users with the possibility to- # assign tax categories to a product. It can be used by tax plugins to properly- # calculate taxes for products.- # Overwrite this method in case your plugin provides a list of tax categories.+ # The returned list will be used to provide staff users with the possibility to+ # assign tax categories to a product. It can be used by tax plugins to properly+ # calculate taxes for products.+ # Overwrite this method in case your plugin provides a list of tax categories.get_tax_rate_type_choices: Callable[[List["TaxType"]], List["TaxType"]]- # Trigger when gift card is created.+ # Trigger when gift card is created.#- # Overwrite this method if you need to trigger specific logic after a gift card is- # created.+ # Overwrite this method if you need to trigger specific logic after a gift card is+ # created.gift_card_created: Callable[["GiftCard", None], None]- # Trigger when gift card is deleted.+ # Trigger when gift card is deleted.#- # Overwrite this method if you need to trigger specific logic after a gift card is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a gift card is+ # deleted.gift_card_deleted: Callable[["GiftCard", None], None]- # Trigger when gift card is updated.+ # Trigger when gift card is updated.#- # Overwrite this method if you need to trigger specific logic after a gift card is- # updated.+ # Overwrite this method if you need to trigger specific logic after a gift card is+ # updated.gift_card_updated: Callable[["GiftCard", None], None]- # Trigger when gift card metadata is updated.+ # Trigger when gift card metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a gift card- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a gift card+ # metadata is updated.gift_card_metadata_updated: Callable[["GiftCard", None], None]- # Trigger when gift card status is changed.+ # Trigger when gift card status is changed.#- # Overwrite this method if you need to trigger specific logic after a gift card- # status is changed.+ # Overwrite this method if you need to trigger specific logic after a gift card+ # status is changed.gift_card_status_changed: Callable[["GiftCard", None], None]initialize_payment: Callable[[dict], InitializedPaymentResponse]- # Trigger before invoice is deleted.+ # Trigger before invoice is deleted.#- # Perform any extra logic before the invoice gets deleted.- # Note there is no need to run invoice.delete() as it will happen in mutation.+ # Perform any extra logic before the invoice gets deleted.+ # Note there is no need to run invoice.delete() as it will happen in mutation.invoice_delete: Callable[["Invoice", Any], Any]- # Trigger when invoice creation starts.- # May return Invoice object.- # Overwrite to create invoice with proper data, call invoice.update_invoice.+ # Trigger when invoice creation starts.+ # May return Invoice object.+ # Overwrite to create invoice with proper data, call invoice.update_invoice.invoice_request: Callable[- ["Order", "Invoice", Union[str, NoneType], Any], Optional["Invoice"]+ ["Order", "Invoice", Union[str, None], Any], Optional["Invoice"]]- # Trigger after invoice is sent.+ # Trigger after invoice is sent.invoice_sent: Callable[["Invoice", str, Any], Any]list_payment_sources: Callable[[str, Any], List["CustomerSource"]]- # Trigger when menu is created.+ # Trigger when menu is created.#- # Overwrite this method if you need to trigger specific logic after a menu is- # created.+ # Overwrite this method if you need to trigger specific logic after a menu is+ # created.menu_created: Callable[["Menu", None], None]- # Trigger when menu is deleted.+ # Trigger when menu is deleted.#- # Overwrite this method if you need to trigger specific logic after a menu is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a menu is+ # deleted.menu_deleted: Callable[["Menu", None], None]- # Trigger when menu is updated.+ # Trigger when menu is updated.#- # Overwrite this method if you need to trigger specific logic after a menu is- # updated.+ # Overwrite this method if you need to trigger specific logic after a menu is+ # updated.menu_updated: Callable[["Menu", None], None]- # Trigger when menu item is created.+ # Trigger when menu item is created.#- # Overwrite this method if you need to trigger specific logic after a menu item is- # created.+ # Overwrite this method if you need to trigger specific logic after a menu item is+ # created.menu_item_created: Callable[["MenuItem", None], None]- # Trigger when menu item is deleted.+ # Trigger when menu item is deleted.#- # Overwrite this method if you need to trigger specific logic after a menu item is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a menu item is+ # deleted.menu_item_deleted: Callable[["MenuItem", None], None]- # Trigger when menu item is updated.+ # Trigger when menu item is updated.#- # Overwrite this method if you need to trigger specific logic after a menu item is- # updated.+ # Overwrite this method if you need to trigger specific logic after a menu item is+ # updated.menu_item_updated: Callable[["MenuItem", None], None]- # Handle notification request.+ # Handle notification request.#- # Overwrite this method if the plugin is responsible for sending notifications.+ # Overwrite this method if the plugin is responsible for sending notifications.notify: Callable[["NotifyEventType", dict, Any], Any]- # Trigger when order is cancelled.+ # Trigger when order is cancelled.#- # Overwrite this method if you need to trigger specific logic when an order is- # canceled.+ # Overwrite this method if you need to trigger specific logic when an order is+ # canceled.order_cancelled: Callable[["Order", Any], Any]- # Trigger when order is confirmed by staff.+ # Trigger when order is confirmed by staff.#- # Overwrite this method if you need to trigger specific logic after an order is- # confirmed.+ # Overwrite this method if you need to trigger specific logic after an order is+ # confirmed.order_confirmed: Callable[["Order", Any], Any]- # Trigger when order is created.+ # Trigger when order is created.#- # Overwrite this method if you need to trigger specific logic after an order is- # created.+ # Overwrite this method if you need to trigger specific logic after an order is+ # created.order_created: Callable[["Order", Any], Any]- # Trigger when order is fulfilled.+ # Trigger when order is fulfilled.#- # Overwrite this method if you need to trigger specific logic when an order is- # fulfilled.+ # Overwrite this method if you need to trigger specific logic when an order is+ # fulfilled.order_fulfilled: Callable[["Order", Any], Any]- # Trigger when order is fully paid.+ # Trigger when order is fully paid.#- # Overwrite this method if you need to trigger specific logic when an order is- # fully paid.+ # Overwrite this method if you need to trigger specific logic when an order is+ # fully paid.order_fully_paid: Callable[["Order", Any], Any]- # Trigger when order is updated.+ # Trigger when order is updated.#- # Overwrite this method if you need to trigger specific logic when an order is- # changed.+ # Overwrite this method if you need to trigger specific logic when an order is+ # changed.order_updated: Callable[["Order", Any], Any]- # Trigger when order metadata is updated.+ # Trigger when order metadata is updated.#- # Overwrite this method if you need to trigger specific logic when an order- # metadata is changed.+ # Overwrite this method if you need to trigger specific logic when an order+ # metadata is changed.order_metadata_updated: Callable[["Order", Any], Any]- # Trigger when page is created.+ # Trigger when page is created.#- # Overwrite this method if you need to trigger specific logic when a page is- # created.+ # Overwrite this method if you need to trigger specific logic when a page is+ # created.page_created: Callable[["Page", Any], Any]- # Trigger when page is deleted.+ # Trigger when page is deleted.#- # Overwrite this method if you need to trigger specific logic when a page is- # deleted.+ # Overwrite this method if you need to trigger specific logic when a page is+ # deleted.page_deleted: Callable[["Page", Any], Any]- # Trigger when page is updated.+ # Trigger when page is updated.#- # Overwrite this method if you need to trigger specific logic when a page is- # updated.+ # Overwrite this method if you need to trigger specific logic when a page is+ # updated.page_updated: Callable[["Page", Any], Any]- # Trigger when page type is created.+ # Trigger when page type is created.#- # Overwrite this method if you need to trigger specific logic when a page type is- # created.+ # Overwrite this method if you need to trigger specific logic when a page type is+ # created.page_type_created: Callable[["PageType", Any], Any]- # Trigger when page type is deleted.+ # Trigger when page type is deleted.#- # Overwrite this method if you need to trigger specific logic when a page type is- # deleted.+ # Overwrite this method if you need to trigger specific logic when a page type is+ # deleted.page_type_deleted: Callable[["PageType", Any], Any]- # Trigger when page type is updated.+ # Trigger when page type is updated.#- # Overwrite this method if you need to trigger specific logic when a page type is- # updated.+ # Overwrite this method if you need to trigger specific logic when a page type is+ # updated.page_type_updated: Callable[["PageType", Any], Any]- # Trigger when permission group is created.+ # Trigger when permission group is created.#- # Overwrite this method if you need to trigger specific logic when a permission- # group is created.+ # Overwrite this method if you need to trigger specific logic when a permission+ # group is created.permission_group_created: Callable[["Group", Any], Any]- # Trigger when permission group type is deleted.+ # Trigger when permission group type is deleted.#- # Overwrite this method if you need to trigger specific logic when a permission- # group is deleted.+ # Overwrite this method if you need to trigger specific logic when a permission+ # group is deleted.permission_group_deleted: Callable[["Group", Any], Any]- # Trigger when permission group is updated.+ # Trigger when permission group is updated.#- # Overwrite this method if you need to trigger specific logic when a permission- # group is updated.+ # Overwrite this method if you need to trigger specific logic when a permission+ # group is updated.permission_group_updated: Callable[["Group", Any], Any]- # Trigger directly before order creation.+ # Trigger directly before order creation.#- # Overwrite this method if you need to trigger specific logic before an order is- # created.+ # Overwrite this method if you need to trigger specific logic before an order is+ # created.preprocess_order_creation: Callable[["CheckoutInfo",List["DiscountInfo"],- Union[Iterable["CheckoutLineInfo"], NoneType],+ Union[Iterable["CheckoutLineInfo"], None],Any,],Any,@@ -793,201 +789,203 @@ class BasePlugin:transaction_action_request: Callable[["TransactionActionData", None], None]- # Trigger when transaction item metadata is updated.+ # Trigger when transaction item metadata is updated.#- # Overwrite this method if you need to trigger specific logic when a transaction- # item metadata is updated.+ # Overwrite this method if you need to trigger specific logic when a transaction+ # item metadata is updated.transaction_item_metadata_updated: Callable[["TransactionItem", Any], Any]- # Trigger when product is created.+ # Trigger when product is created.#- # Overwrite this method if you need to trigger specific logic after a product is- # created.+ # Overwrite this method if you need to trigger specific logic after a product is+ # created.product_created: Callable[["Product", Any], Any]- # Trigger when product is deleted.+ # Trigger when product is deleted.#- # Overwrite this method if you need to trigger specific logic after a product is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a product is+ # deleted.product_deleted: Callable[["Product", List[int], Any], Any]- # Trigger when product is updated.+ # Trigger when product is updated.#- # Overwrite this method if you need to trigger specific logic after a product is- # updated.+ # Overwrite this method if you need to trigger specific logic after a product is+ # updated.product_updated: Callable[["Product", Any], Any]- # Trigger when product metadata is updated.+ # Trigger when product metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a product- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a product+ # metadata is updated.product_metadata_updated: Callable[["Product", Any], Any]- # Trigger when product variant is created.+ # Trigger when product variant is created.#- # Overwrite this method if you need to trigger specific logic after a product- # variant is created.+ # Overwrite this method if you need to trigger specific logic after a product+ # variant is created.product_variant_created: Callable[["ProductVariant", Any], Any]- # Trigger when product variant is deleted.+ # Trigger when product variant is deleted.#- # Overwrite this method if you need to trigger specific logic after a product- # variant is deleted.+ # Overwrite this method if you need to trigger specific logic after a product+ # variant is deleted.product_variant_deleted: Callable[["ProductVariant", Any], Any]- # Trigger when product variant is updated.+ # Trigger when product variant is updated.#- # Overwrite this method if you need to trigger specific logic after a product- # variant is updated.+ # Overwrite this method if you need to trigger specific logic after a product+ # variant is updated.product_variant_updated: Callable[["ProductVariant", Any], Any]- # Trigger when product variant metadata is updated.+ # Trigger when product variant metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a product- # variant metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a product+ # variant metadata is updated.product_variant_metadata_updated: Callable[["ProductVariant", Any], Any]refund_payment: Callable[["PaymentData", Any], GatewayResponse]- # Trigger when sale is created.+ # Trigger when sale is created.## Overwrite this method if you need to trigger specific logic after sale is created.sale_created: Callable[["Sale", DefaultDict[str, Set[str]], Any], Any]- # Trigger when sale is deleted.+ # Trigger when sale is deleted.#- # Overwrite this method if you need to trigger specific logic after sale is deleted.+ # Overwrite this method if you need to trigger specific logic after+ # a sale is deleted.sale_deleted: Callable[["Sale", DefaultDict[str, Set[str]], Any], Any]- # Trigger when sale is updated.+ # Trigger when sale is updated.#- # Overwrite this method if you need to trigger specific logic after sale is updated.+ # Overwrite this method if you need to trigger specific logic after+ # a sale is updated.sale_updated: Callable[["Sale", DefaultDict[str, Set[str]], DefaultDict[str, Set[str]], Any], Any]- # Trigger when shipping price is created.+ # Trigger when shipping price is created.#- # Overwrite this method if you need to trigger specific logic after a shipping- # price is created.+ # Overwrite this method if you need to trigger specific logic after a shipping+ # price is created.shipping_price_created: Callable[["ShippingMethod", None], None]- # Trigger when shipping price is deleted.+ # Trigger when shipping price is deleted.#- # Overwrite this method if you need to trigger specific logic after a shipping- # price is deleted.+ # Overwrite this method if you need to trigger specific logic after a shipping+ # price is deleted.shipping_price_deleted: Callable[["ShippingMethod", None], None]- # Trigger when shipping price is updated.+ # Trigger when shipping price is updated.#- # Overwrite this method if you need to trigger specific logic after a shipping- # price is updated.+ # Overwrite this method if you need to trigger specific logic after a shipping+ # price is updated.shipping_price_updated: Callable[["ShippingMethod", None], None]- # Trigger when shipping zone is created.+ # Trigger when shipping zone is created.#- # Overwrite this method if you need to trigger specific logic after a shipping zone- # is created.+ # Overwrite this method if you need to trigger specific logic after a shipping zone+ # is created.shipping_zone_created: Callable[["ShippingZone", None], None]- # Trigger when shipping zone is deleted.+ # Trigger when shipping zone is deleted.#- # Overwrite this method if you need to trigger specific logic after a shipping zone- # is deleted.+ # Overwrite this method if you need to trigger specific logic after a shipping zone+ # is deleted.shipping_zone_deleted: Callable[["ShippingZone", None], None]- # Trigger when shipping zone is updated.+ # Trigger when shipping zone is updated.#- # Overwrite this method if you need to trigger specific logic after a shipping zone- # is updated.+ # Overwrite this method if you need to trigger specific logic after a shipping zone+ # is updated.shipping_zone_updated: Callable[["ShippingZone", None], None]- # Trigger when shipping zone metadata is updated.+ # Trigger when shipping zone metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a shipping zone- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a shipping zone+ # metadata is updated.shipping_zone_metadata_updated: Callable[["ShippingZone", None], None]- # Define if storefront should add info about taxes to the price.+ # Define if storefront should add info about taxes to the price.#- # It is used only by the old storefront. The returned value determines if- # storefront should append info to the price about "including/excluding X% VAT".+ # It is used only by the old storefront. The returned value determines if+ # storefront should append info to the price about "including/excluding X% VAT".show_taxes_on_storefront: Callable[[bool], bool]- # Trigger when staff user is created.+ # Trigger when staff user is created.#- # Overwrite this method if you need to trigger specific logic after a staff user is- # created.+ # Overwrite this method if you need to trigger specific logic after a staff user is+ # created.staff_created: Callable[["User", Any], Any]- # Trigger when staff user is updated.+ # Trigger when staff user is updated.#- # Overwrite this method if you need to trigger specific logic after a staff user is- # updated.+ # Overwrite this method if you need to trigger specific logic after a staff user is+ # updated.staff_updated: Callable[["User", Any], Any]- # Trigger when staff user is deleted.+ # Trigger when staff user is deleted.#- # Overwrite this method if you need to trigger specific logic after a staff user is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a staff user is+ # deleted.staff_deleted: Callable[["User", Any], Any]- # Trigger when tracking number is updated.+ # Trigger when tracking number is updated.tracking_number_updated: Callable[["Fulfillment", Any], Any]void_payment: Callable[["PaymentData", Any], GatewayResponse]- # Trigger when warehouse is created.+ # Trigger when warehouse is created.#- # Overwrite this method if you need to trigger specific logic after a warehouse is- # created.+ # Overwrite this method if you need to trigger specific logic after a warehouse is+ # created.warehouse_created: Callable[["Warehouse", None], None]- # Trigger when warehouse is deleted.+ # Trigger when warehouse is deleted.#- # Overwrite this method if you need to trigger specific logic after a warehouse is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a warehouse is+ # deleted.warehouse_deleted: Callable[["Warehouse", None], None]- # Trigger when warehouse is updated.+ # Trigger when warehouse is updated.#- # Overwrite this method if you need to trigger specific logic after a warehouse is- # updated.+ # Overwrite this method if you need to trigger specific logic after a warehouse is+ # updated.warehouse_updated: Callable[["Warehouse", None], None]- # Trigger when warehouse metadata is updated.+ # Trigger when warehouse metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a warehouse- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a warehouse+ # metadata is updated.warehouse_metadata_updated: Callable[["Warehouse", None], None]- # Trigger when voucher is created.+ # Trigger when voucher is created.#- # Overwrite this method if you need to trigger specific logic after a voucher is- # created.+ # Overwrite this method if you need to trigger specific logic after a voucher is+ # created.voucher_created: Callable[["Voucher", None], None]- # Trigger when voucher is deleted.+ # Trigger when voucher is deleted.#- # Overwrite this method if you need to trigger specific logic after a voucher is- # deleted.+ # Overwrite this method if you need to trigger specific logic after a voucher is+ # deleted.voucher_deleted: Callable[["Voucher", None], None]- # Trigger when voucher is updated.+ # Trigger when voucher is updated.#- # Overwrite this method if you need to trigger specific logic after a voucher is- # updated.+ # Overwrite this method if you need to trigger specific logic after a voucher is+ # updated.voucher_updated: Callable[["Voucher", None], None]- # Trigger when voucher metadata is updated.+ # Trigger when voucher metadata is updated.#- # Overwrite this method if you need to trigger specific logic after a voucher- # metadata is updated.+ # Overwrite this method if you need to trigger specific logic after a voucher+ # metadata is updated.voucher_metadata_updated: Callable[["Voucher", None], None]- # Handle received http request.+ # Handle received http request.#- # Overwrite this method if the plugin expects the incoming requests.+ # Overwrite this method if the plugin expects the incoming requests.webhook: Callable[[WSGIRequest, str, Any], HttpResponse]# Triggers retry mechanism for event delivery@@ -999,9 +997,9 @@ class BasePlugin:# but only once the permissions are checked.## Returns one of:- # - null if the execution shall continue- # - an execution result- # - graphql.GraphQLError+ # - null if the execution shall continue+ # - an execution result+ # - graphql.GraphQLErrorperform_mutation: Callable[[Optional[Union[ExecutionResult, GraphQLError]], # previous valuediff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex a74ec3b94c..7232798c6b 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -37,7 +37,6 @@ from .base_plugin import ExcludedShippingMethod, ExternalAccessTokensfrom .models import PluginConfigurationif TYPE_CHECKING:- # flake8: noqafrom ..account.models import Address, Group, Userfrom ..app.models import Appfrom ..attribute.models import Attribute, AttributeValuediff --git a/saleor/plugins/tests/sample_plugins.py b/saleor/plugins/tests/sample_plugins.pyindex ffdb19250d..9a0cdc31b3 100644--- a/saleor/plugins/tests/sample_plugins.py+++ b/saleor/plugins/tests/sample_plugins.py@@ -4,7 +4,6 @@ from typing import (Any,DefaultDict,Iterable,- List,Optional,Set,Tuple,@@ -25,11 +24,10 @@ from ...order.interface import OrderTaxedPricesDatafrom ..base_plugin import BasePlugin, ConfigurationTypeField, ExternalAccessTokensif TYPE_CHECKING:- # flake8: noqafrom ...account.models import Address- from ...channel.models import Channelfrom ...checkout.fetch import CheckoutInfo, CheckoutLineInfo- from ...checkout.models import Checkout, CheckoutLine+ from ...checkout.models import Checkout+ from ...core.models import EventDeliveryfrom ...discount import DiscountInfofrom ...discount.models import Salefrom ...order.models import Order, OrderLinediff --git a/saleor/plugins/user_email/tests/test_tasks.py b/saleor/plugins/user_email/tests/test_tasks.pyindex 08a8a178ff..6681a2815c 100644--- a/saleor/plugins/user_email/tests/test_tasks.py+++ b/saleor/plugins/user_email/tests/test_tasks.py@@ -1223,7 +1223,6 @@ def test_send_gift_card_email_task_by_user_resending("requester_app_id": None,"recipient_email": recipient_email,"resending": True,- "recipient_email": recipient_email,"gift_card": {"id": to_global_id_or_none(gift_card),"code": gift_card.code,@@ -1276,14 +1275,12 @@ def test_send_gift_card_email_task_by_app("requester_app_id": to_global_id_or_none(app),"recipient_email": recipient_email,"resending": False,- "recipient_email": recipient_email,"gift_card": {"id": to_global_id_or_none(gift_card),"code": gift_card.code,"balance": gift_card.current_balance_amount,"currency": gift_card.currency,},- "recipient_email": recipient_email,}user_email_plugin(diff --git a/saleor/plugins/vatlayer/plugin.py b/saleor/plugins/vatlayer/plugin.pyindex 3a11f2f022..dd7ee30e4a 100644--- a/saleor/plugins/vatlayer/plugin.py+++ b/saleor/plugins/vatlayer/plugin.py@@ -20,10 +20,7 @@ from ...core.prices import quantize_pricefrom ...core.taxes import TaxType, zero_money, zero_taxed_moneyfrom ...discount import OrderDiscountType, VoucherTypefrom ...order.interface import OrderTaxedPricesData-from ...order.utils import (- get_total_order_discount_excluding_shipping,- get_voucher_discount_assigned_to_order,-)+from ...order.utils import get_total_order_discount_excluding_shippingfrom ...plugins.error_codes import PluginErrorCodefrom ...product.models import ProductTypefrom ..base_plugin import BasePlugin, ConfigurationTypeField@@ -38,7 +35,6 @@ from . import ()if TYPE_CHECKING:- # flake8: noqafrom ...account.models import Addressfrom ...channel.models import Channelfrom ...checkout.fetch import CheckoutInfo, CheckoutLineInfodiff --git a/saleor/plugins/webhook/tests/test_shipping_webhook.py b/saleor/plugins/webhook/tests/test_shipping_webhook.pyindex 6f57ba6246..142d6b70aa 100644--- a/saleor/plugins/webhook/tests/test_shipping_webhook.py+++ b/saleor/plugins/webhook/tests/test_shipping_webhook.py@@ -407,9 +407,11 @@ def test_order_available_shipping_methods():# givensettings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]- mocked_webhook.side_effect = lambda *args, **kwargs: webhook_response(- order_with_lines.shipping_method- )++ def respond(*args, **kwargs):+ return webhook_response(order_with_lines.shipping_method)++ mocked_webhook.side_effect = respondstaff_api_client.user.user_permissions.add(permission_manage_orders)# whenresponse = staff_api_client.post_graphql(ORDER_QUERY_SHIPPING_METHOD)diff --git a/saleor/product/migrations/0001_initial.py b/saleor/product/migrations/0001_initial.pyindex 7012845b64..d6ffc2adc8 100644--- a/saleor/product/migrations/0001_initial.py+++ b/saleor/product/migrations/0001_initial.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from decimal import Decimalimport django.core.validatorsdiff --git a/saleor/product/migrations/0002_auto_20150722_0545.py b/saleor/product/migrations/0002_auto_20150722_0545.pyindex fadf6ec473..775e5901e4 100644--- a/saleor/product/migrations/0002_auto_20150722_0545.py+++ b/saleor/product/migrations/0002_auto_20150722_0545.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from django.db import migrations, modelsdiff --git a/saleor/product/migrations/0003_auto_20150820_1955.py b/saleor/product/migrations/0003_auto_20150820_1955.pyindex 0adefbec86..3f3c41dbba 100644--- a/saleor/product/migrations/0003_auto_20150820_1955.py+++ b/saleor/product/migrations/0003_auto_20150820_1955.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/product/migrations/0003_auto_20150820_2016.py b/saleor/product/migrations/0003_auto_20150820_2016.pyindex 0ccd5f93d2..2528bd246e 100644--- a/saleor/product/migrations/0003_auto_20150820_2016.py+++ b/saleor/product/migrations/0003_auto_20150820_2016.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from django.db import migrations, modelsdiff --git a/saleor/product/migrations/0004_merge.py b/saleor/product/migrations/0004_merge.pyindex c2d351289d..549663d294 100644--- a/saleor/product/migrations/0004_merge.py+++ b/saleor/product/migrations/0004_merge.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from django.db import migrationsdiff --git a/saleor/product/migrations/0005_auto_20150825_1433.py b/saleor/product/migrations/0005_auto_20150825_1433.pyindex f8bdd6bfbd..972cb7d1b7 100644--- a/saleor/product/migrations/0005_auto_20150825_1433.py+++ b/saleor/product/migrations/0005_auto_20150825_1433.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from django.db import migrations, modelsdiff --git a/saleor/product/migrations/0006_product_updated_at.py b/saleor/product/migrations/0006_product_updated_at.pyindex 54487d11f1..b0f497bf99 100644--- a/saleor/product/migrations/0006_product_updated_at.py+++ b/saleor/product/migrations/0006_product_updated_at.py@@ -1,6 +1,3 @@-# -*- coding: utf-8 -*--from __future__ import unicode_literals-from django.db import migrations, modelsdiff --git a/saleor/product/migrations/0007_auto_20160112_1025.py b/saleor/product/migrations/0007_auto_20160112_1025.pyindex e83e031f42..c8a9258625 100644--- a/saleor/product/migrations/0007_auto_20160112_1025.py+++ b/saleor/product/migrations/0007_auto_20160112_1025.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-12 16:25-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/product/migrations/0008_auto_20160114_0733.py b/saleor/product/migrations/0008_auto_20160114_0733.pyindex 1b54875a37..db48750e22 100644--- a/saleor/product/migrations/0008_auto_20160114_0733.py+++ b/saleor/product/migrations/0008_auto_20160114_0733.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-14 13:33-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/product/migrations/0009_discount_categories.py b/saleor/product/migrations/0009_discount_categories.pyindex beba51a0fd..f573427ef9 100644--- a/saleor/product/migrations/0009_discount_categories.py+++ b/saleor/product/migrations/0009_discount_categories.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-14 14:29-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/product/migrations/0010_auto_20160129_0826.py b/saleor/product/migrations/0010_auto_20160129_0826.pyindex d659809923..1415ccc581 100644--- a/saleor/product/migrations/0010_auto_20160129_0826.py+++ b/saleor/product/migrations/0010_auto_20160129_0826.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-29 14:26-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/product/migrations/0011_stock_quantity_allocated.py b/saleor/product/migrations/0011_stock_quantity_allocated.pyindex f6d07059ea..05843562e0 100644--- a/saleor/product/migrations/0011_stock_quantity_allocated.py+++ b/saleor/product/migrations/0011_stock_quantity_allocated.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.2 on 2016-02-08 14:45from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0012_auto_20160218_0812.py b/saleor/product/migrations/0012_auto_20160218_0812.pyindex 8d7d3bfeb0..21b42d4805 100644--- a/saleor/product/migrations/0012_auto_20160218_0812.py+++ b/saleor/product/migrations/0012_auto_20160218_0812.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-02-18 14:12from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0013_auto_20161130_0608.py b/saleor/product/migrations/0013_auto_20161130_0608.pyindex 2186e55767..98ec7a9d7c 100644--- a/saleor/product/migrations/0013_auto_20161130_0608.py+++ b/saleor/product/migrations/0013_auto_20161130_0608.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-11-30 12:08from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0013_auto_20161207_0555.py b/saleor/product/migrations/0013_auto_20161207_0555.pyindex c68077ab91..d2229f0f7a 100644--- a/saleor/product/migrations/0013_auto_20161207_0555.py+++ b/saleor/product/migrations/0013_auto_20161207_0555.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 11:55from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0014_auto_20161207_0840.py b/saleor/product/migrations/0014_auto_20161207_0840.pyindex c009a632d9..aa055d02fd 100644--- a/saleor/product/migrations/0014_auto_20161207_0840.py+++ b/saleor/product/migrations/0014_auto_20161207_0840.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 14:40from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0014_remove_productvariant_attributes.py b/saleor/product/migrations/0014_remove_productvariant_attributes.pyindex 20b30c7f92..ab98067dcf 100644--- a/saleor/product/migrations/0014_remove_productvariant_attributes.py+++ b/saleor/product/migrations/0014_remove_productvariant_attributes.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-11-30 12:22from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0015_productvariant_attributes.py b/saleor/product/migrations/0015_productvariant_attributes.pyindex f34560c4e8..95888258fd 100644--- a/saleor/product/migrations/0015_productvariant_attributes.py+++ b/saleor/product/migrations/0015_productvariant_attributes.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-11-30 12:26from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0015_transfer_locations.py b/saleor/product/migrations/0015_transfer_locations.pyindex 22a6e498c4..d7633c4d0b 100644--- a/saleor/product/migrations/0015_transfer_locations.py+++ b/saleor/product/migrations/0015_transfer_locations.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 14:41from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0016_auto_20161204_0311.py b/saleor/product/migrations/0016_auto_20161204_0311.pyindex 1439a77d04..2a8198f12a 100644--- a/saleor/product/migrations/0016_auto_20161204_0311.py+++ b/saleor/product/migrations/0016_auto_20161204_0311.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-04 09:11from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0016_auto_20161207_0843.py b/saleor/product/migrations/0016_auto_20161207_0843.pyindex 29dafebe21..41808e3ed2 100644--- a/saleor/product/migrations/0016_auto_20161207_0843.py+++ b/saleor/product/migrations/0016_auto_20161207_0843.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 14:43from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0017_attributechoicevalue_slug.py b/saleor/product/migrations/0017_attributechoicevalue_slug.pyindex ce60448bd1..b7c08dfa6d 100644--- a/saleor/product/migrations/0017_attributechoicevalue_slug.py+++ b/saleor/product/migrations/0017_attributechoicevalue_slug.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-12 13:24from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0017_remove_stock_location.py b/saleor/product/migrations/0017_remove_stock_location.pyindex 48631ad4fc..84f36aeb65 100644--- a/saleor/product/migrations/0017_remove_stock_location.py+++ b/saleor/product/migrations/0017_remove_stock_location.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 14:43from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0018_auto_20161207_0844.py b/saleor/product/migrations/0018_auto_20161207_0844.pyindex 8e5fb20973..cfb3d01102 100644--- a/saleor/product/migrations/0018_auto_20161207_0844.py+++ b/saleor/product/migrations/0018_auto_20161207_0844.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-07 14:44from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0018_auto_20161212_0725.py b/saleor/product/migrations/0018_auto_20161212_0725.pyindex bc71415b8d..a33b2c3689 100644--- a/saleor/product/migrations/0018_auto_20161212_0725.py+++ b/saleor/product/migrations/0018_auto_20161212_0725.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-12 13:25from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0019_auto_20161212_0230.py b/saleor/product/migrations/0019_auto_20161212_0230.pyindex 06476ecd81..6c9aee4361 100644--- a/saleor/product/migrations/0019_auto_20161212_0230.py+++ b/saleor/product/migrations/0019_auto_20161212_0230.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-12 08:30from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0022_auto_20161212_0301.py b/saleor/product/migrations/0022_auto_20161212_0301.pyindex 5c0fd51695..78e509c33e 100644--- a/saleor/product/migrations/0022_auto_20161212_0301.py+++ b/saleor/product/migrations/0022_auto_20161212_0301.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-12 09:01from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0023_auto_20161211_1912.py b/saleor/product/migrations/0023_auto_20161211_1912.pyindex b63f6332db..18d9dcf6e5 100644--- a/saleor/product/migrations/0023_auto_20161211_1912.py+++ b/saleor/product/migrations/0023_auto_20161211_1912.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-12 01:12from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0025_auto_20161219_0517.py b/saleor/product/migrations/0025_auto_20161219_0517.pyindex 8655a132e3..e723907c61 100644--- a/saleor/product/migrations/0025_auto_20161219_0517.py+++ b/saleor/product/migrations/0025_auto_20161219_0517.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-19 11:17from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0026_auto_20161230_0347.py b/saleor/product/migrations/0026_auto_20161230_0347.pyindex bb55d75c2b..43d8b73358 100644--- a/saleor/product/migrations/0026_auto_20161230_0347.py+++ b/saleor/product/migrations/0026_auto_20161230_0347.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-30 09:47-from __future__ import unicode_literalsfrom django.db import migrations, modelsdiff --git a/saleor/product/migrations/0026_merge_20161221_0845.py b/saleor/product/migrations/0026_merge_20161221_0845.pyindex 84686051d7..8b2e38682b 100644--- a/saleor/product/migrations/0026_merge_20161221_0845.py+++ b/saleor/product/migrations/0026_merge_20161221_0845.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2016-12-21 14:45from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0027_auto_20170113_0435.py b/saleor/product/migrations/0027_auto_20170113_0435.pyindex b01239cabc..dc274e7718 100644--- a/saleor/product/migrations/0027_auto_20170113_0435.py+++ b/saleor/product/migrations/0027_auto_20170113_0435.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2017-01-13 10:35from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0028_merge_20170116_1016.py b/saleor/product/migrations/0028_merge_20170116_1016.pyindex 7e525d04d0..13f0a7606c 100644--- a/saleor/product/migrations/0028_merge_20170116_1016.py+++ b/saleor/product/migrations/0028_merge_20170116_1016.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2017-01-16 16:16from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0029_product_is_featured.py b/saleor/product/migrations/0029_product_is_featured.pyindex 5147ef2902..a980f18c4a 100644--- a/saleor/product/migrations/0029_product_is_featured.py+++ b/saleor/product/migrations/0029_product_is_featured.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-01-30 10:12from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0030_auto_20170206_0407.py b/saleor/product/migrations/0030_auto_20170206_0407.pyindex 143c053b3b..2c1c039fb8 100644--- a/saleor/product/migrations/0030_auto_20170206_0407.py+++ b/saleor/product/migrations/0030_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0031_auto_20170206_0601.py b/saleor/product/migrations/0031_auto_20170206_0601.pyindex a427245269..0b9dcebe91 100644--- a/saleor/product/migrations/0031_auto_20170206_0601.py+++ b/saleor/product/migrations/0031_auto_20170206_0601.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 12:01from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0032_auto_20170216_0438.py b/saleor/product/migrations/0032_auto_20170216_0438.pyindex d18431f011..61e5f2c332 100644--- a/saleor/product/migrations/0032_auto_20170216_0438.py+++ b/saleor/product/migrations/0032_auto_20170216_0438.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-16 10:38from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0033_auto_20170227_0757.py b/saleor/product/migrations/0033_auto_20170227_0757.pyindex 61378db5ef..ce0da4815c 100644--- a/saleor/product/migrations/0033_auto_20170227_0757.py+++ b/saleor/product/migrations/0033_auto_20170227_0757.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-27 13:57from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0034_product_is_published.py b/saleor/product/migrations/0034_product_is_published.pyindex 1528a1b13a..829d05430e 100644--- a/saleor/product/migrations/0034_product_is_published.py+++ b/saleor/product/migrations/0034_product_is_published.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.6 on 2017-04-05 09:08from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0035_auto_20170919_0846.py b/saleor/product/migrations/0035_auto_20170919_0846.pyindex c78effa648..e44fca5cc1 100644--- a/saleor/product/migrations/0035_auto_20170919_0846.py+++ b/saleor/product/migrations/0035_auto_20170919_0846.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-19 13:46from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0036_auto_20171115_0608.py b/saleor/product/migrations/0036_auto_20171115_0608.pyindex 6794c46165..28d0541315 100644--- a/saleor/product/migrations/0036_auto_20171115_0608.py+++ b/saleor/product/migrations/0036_auto_20171115_0608.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-15 12:08from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0037_auto_20171124_0847.py b/saleor/product/migrations/0037_auto_20171124_0847.pyindex ca761229dd..31f2c98a7b 100644--- a/saleor/product/migrations/0037_auto_20171124_0847.py+++ b/saleor/product/migrations/0037_auto_20171124_0847.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-24 14:47from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0037_auto_20171129_1004.py b/saleor/product/migrations/0037_auto_20171129_1004.pyindex 90663ab843..a7abffc4d1 100644--- a/saleor/product/migrations/0037_auto_20171129_1004.py+++ b/saleor/product/migrations/0037_auto_20171129_1004.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/product/migrations/0038_auto_20171129_0616.py b/saleor/product/migrations/0038_auto_20171129_0616.pyindex 2d22118339..51a1518fe3 100644--- a/saleor/product/migrations/0038_auto_20171129_0616.py+++ b/saleor/product/migrations/0038_auto_20171129_0616.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 12:16from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0039_merge_20171130_0727.py b/saleor/product/migrations/0039_merge_20171130_0727.pyindex c1f02e11f1..d97ff4875a 100644--- a/saleor/product/migrations/0039_merge_20171130_0727.py+++ b/saleor/product/migrations/0039_merge_20171130_0727.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-30 13:27from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0040_auto_20171205_0428.py b/saleor/product/migrations/0040_auto_20171205_0428.pyindex 7ff2989124..9aea79cd06 100644--- a/saleor/product/migrations/0040_auto_20171205_0428.py+++ b/saleor/product/migrations/0040_auto_20171205_0428.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-05 10:28from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0041_auto_20171205_0546.py b/saleor/product/migrations/0041_auto_20171205_0546.pyindex 3e352cc42d..9c01331c91 100644--- a/saleor/product/migrations/0041_auto_20171205_0546.py+++ b/saleor/product/migrations/0041_auto_20171205_0546.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-05 11:46-from __future__ import unicode_literalsfrom django.db import migrationsdiff --git a/saleor/product/migrations/0042_auto_20171206_0501.py b/saleor/product/migrations/0042_auto_20171206_0501.pyindex d7b4831fce..c2d032b302 100644--- a/saleor/product/migrations/0042_auto_20171206_0501.py+++ b/saleor/product/migrations/0042_auto_20171206_0501.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-06 11:01from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0043_auto_20171207_0839.py b/saleor/product/migrations/0043_auto_20171207_0839.pyindex 4f61e3a124..179a2754a1 100644--- a/saleor/product/migrations/0043_auto_20171207_0839.py+++ b/saleor/product/migrations/0043_auto_20171207_0839.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-12-07 14:39from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0044_auto_20180108_0814.py b/saleor/product/migrations/0044_auto_20180108_0814.pyindex cb68af0559..7811d65736 100644--- a/saleor/product/migrations/0044_auto_20180108_0814.py+++ b/saleor/product/migrations/0044_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0045_md_to_html.py b/saleor/product/migrations/0045_md_to_html.pyindex ab35989b12..e7a3990968 100644--- a/saleor/product/migrations/0045_md_to_html.py+++ b/saleor/product/migrations/0045_md_to_html.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-15 11:16from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0046_product_category.py b/saleor/product/migrations/0046_product_category.pyindex de14f611a3..71f0e6ff63 100644--- a/saleor/product/migrations/0046_product_category.py+++ b/saleor/product/migrations/0046_product_category.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-16 11:56from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0047_auto_20180117_0359.py b/saleor/product/migrations/0047_auto_20180117_0359.pyindex df4b7541be..3bef9ce018 100644--- a/saleor/product/migrations/0047_auto_20180117_0359.py+++ b/saleor/product/migrations/0047_auto_20180117_0359.py@@ -1,6 +1,4 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.9 on 2018-01-17 09:59-from __future__ import unicode_literalsimport django.db.models.deletionfrom django.db import migrations, modelsdiff --git a/saleor/product/migrations/0048_product_class_to_type.py b/saleor/product/migrations/0048_product_class_to_type.pyindex b492eefa89..878c81a6ef 100644--- a/saleor/product/migrations/0048_product_class_to_type.py+++ b/saleor/product/migrations/0048_product_class_to_type.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-15 10:28from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0049_collection.py b/saleor/product/migrations/0049_collection.pyindex 8066c3b391..3322ad6b4c 100644--- a/saleor/product/migrations/0049_collection.py+++ b/saleor/product/migrations/0049_collection.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-24 14:13from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0050_auto_20180131_0746.py b/saleor/product/migrations/0050_auto_20180131_0746.pyindex 834794dd18..9070432947 100644--- a/saleor/product/migrations/0050_auto_20180131_0746.py+++ b/saleor/product/migrations/0050_auto_20180131_0746.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-31 13:46from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0051_auto_20180202_1106.py b/saleor/product/migrations/0051_auto_20180202_1106.pyindex 4291bddbb9..180af02ec7 100644--- a/saleor/product/migrations/0051_auto_20180202_1106.py+++ b/saleor/product/migrations/0051_auto_20180202_1106.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11 on 2018-02-02 17:06from __future__ import unicode_literalsdiff --git a/saleor/product/migrations/0059_generate_variant_name_from_attrs.py b/saleor/product/migrations/0059_generate_variant_name_from_attrs.pyindex 1e26473c93..5b18b92e66 100644--- a/saleor/product/migrations/0059_generate_variant_name_from_attrs.py+++ b/saleor/product/migrations/0059_generate_variant_name_from_attrs.py@@ -1,6 +1,5 @@# Generated by Django 2.0.2 on 2018-03-11 18:54from collections import defaultdict-from typing import Listfrom django.db import migrationsdiff --git a/saleor/product/models.py b/saleor/product/models.pyindex 5da0e7ef36..5abe282bc6 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -1,5 +1,5 @@import datetime-from typing import TYPE_CHECKING, Any, Iterable, Optional, Union+from typing import TYPE_CHECKING, Iterable, Optional, Unionfrom uuid import uuid4import graphene@@ -50,7 +50,6 @@ from ..core.permissions import ()from ..core.units import WeightUnitsfrom ..core.utils import build_absolute_uri-from ..core.utils.draftjs import json_content_to_raw_textfrom ..core.utils.editorjs import clean_editor_jsfrom ..core.utils.translations import Translation, TranslationProxyfrom ..core.weight import zero_weight@@ -60,11 +59,8 @@ from ..seo.models import SeoModel, SeoModelTranslationfrom . import ProductMediaTypes, ProductTypeKindif TYPE_CHECKING:- # flake8: noqafrom decimal import Decimal- from django.db.models import OrderBy-from ..account.models import Userfrom ..app.models import Appdiff --git a/saleor/product/utils/__init__.py b/saleor/product/utils/__init__.pyindex 0d535d88c3..d8fecd8b72 100644--- a/saleor/product/utils/__init__.py+++ b/saleor/product/utils/__init__.py@@ -6,7 +6,6 @@ from ..models import Product, ProductChannelListingfrom ..tasks import update_products_discounted_prices_taskif TYPE_CHECKING:- # flake8: noqafrom datetime import date, datetimefrom uuid import UUID@@ -69,7 +68,9 @@ def delete_categories(categories_ids: List[str], manager):def collect_categories_tree_products(category: "Category") -> "QuerySet[Product]":"""Collect products from all levels in category tree."""- products = category.products.prefetched_for_webhook(single_object=False) # type: ignore+ products = category.products.prefetched_for_webhook( # type: ignore+ single_object=False+ )descendants = category.get_descendants()for descendant in descendants:products = products | descendant.products.all()diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.pyindex db0e9f703d..cb34663bd0 100644--- a/saleor/product/utils/availability.py+++ b/saleor/product/utils/availability.py@@ -1,7 +1,6 @@from dataclasses import dataclassfrom typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union-from django.conf import settingsfrom django_countries.fields import Countryfrom prices import MoneyRange, TaxedMoney, TaxedMoneyRange@@ -18,7 +17,6 @@ from ...product.models import ()if TYPE_CHECKING:- # flake8: noqafrom ...plugins.manager import PluginsManagerdiff --git a/saleor/product/utils/variants.py b/saleor/product/utils/variants.pyindex b13cb4f3f3..857b3d6fe8 100644--- a/saleor/product/utils/variants.py+++ b/saleor/product/utils/variants.py@@ -17,9 +17,8 @@ def generate_and_set_variant_name(assignment__variant_selection=True,assignment__attribute__type=AttributeType.PRODUCT_TYPE,)- for (- attribute_rel- ) in variant_selection_attributes.iterator(): # type: AssignedVariantAttribute+ attribute_rel: AssignedVariantAttribute+ for attribute_rel in variant_selection_attributes.iterator():values_qs = attribute_rel.values.all()translated_values = [str(value.translated) for value in values_qs]attributes_display.append(", ".join(translated_values))diff --git a/saleor/settings.py b/saleor/settings.pyindex c3ed605d93..23cda89a6d 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -1,5 +1,6 @@import astimport logging+import osimport os.pathimport warningsfrom datetime import timedeltadiff --git a/saleor/shipping/migrations/0001_initial.py b/saleor/shipping/migrations/0001_initial.pyindex 519493f680..02ec388615 100644--- a/saleor/shipping/migrations/0001_initial.py+++ b/saleor/shipping/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9.1 on 2016-01-19 10:18from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0002_auto_20160906_0741.py b/saleor/shipping/migrations/0002_auto_20160906_0741.pyindex 4c5517b903..622fa7c72c 100644--- a/saleor/shipping/migrations/0002_auto_20160906_0741.py+++ b/saleor/shipping/migrations/0002_auto_20160906_0741.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.1 on 2016-09-06 12:41from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0003_auto_20170116_0700.py b/saleor/shipping/migrations/0003_auto_20170116_0700.pyindex 0808138af0..cea9aa92cd 100644--- a/saleor/shipping/migrations/0003_auto_20170116_0700.py+++ b/saleor/shipping/migrations/0003_auto_20170116_0700.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.9 on 2017-01-16 13:00from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0004_auto_20170206_0407.py b/saleor/shipping/migrations/0004_auto_20170206_0407.pyindex febf3c799d..40ddac6d44 100644--- a/saleor/shipping/migrations/0004_auto_20170206_0407.py+++ b/saleor/shipping/migrations/0004_auto_20170206_0407.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-06 10:07from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0005_auto_20170906_0556.py b/saleor/shipping/migrations/0005_auto_20170906_0556.pyindex 20a45e5992..63d8de62d3 100644--- a/saleor/shipping/migrations/0005_auto_20170906_0556.py+++ b/saleor/shipping/migrations/0005_auto_20170906_0556.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-06 10:56from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0006_auto_20171109_0908.py b/saleor/shipping/migrations/0006_auto_20171109_0908.pyindex 6fe59679ab..283b65b3fb 100644--- a/saleor/shipping/migrations/0006_auto_20171109_0908.py+++ b/saleor/shipping/migrations/0006_auto_20171109_0908.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-09 15:08from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0007_auto_20171129_1004.py b/saleor/shipping/migrations/0007_auto_20171129_1004.pyindex d4a94e3127..a8be10d642 100644--- a/saleor/shipping/migrations/0007_auto_20171129_1004.py+++ b/saleor/shipping/migrations/0007_auto_20171129_1004.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-29 16:04from __future__ import unicode_literalsdiff --git a/saleor/shipping/migrations/0008_auto_20180108_0814.py b/saleor/shipping/migrations/0008_auto_20180108_0814.pyindex 564086a4df..5f3dff03a8 100644--- a/saleor/shipping/migrations/0008_auto_20180108_0814.py+++ b/saleor/shipping/migrations/0008_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 00a493b656..b39f4806d4 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -21,7 +21,6 @@ from . import PostalCodeRuleInclusionType, ShippingMethodTypefrom .postal_codes import filter_shipping_methods_by_postal_code_rulesif TYPE_CHECKING:- # flake8: noqafrom ..checkout.models import Checkoutfrom ..order.models import Orderdiff --git a/saleor/site/migrations/0001_initial.py b/saleor/site/migrations/0001_initial.pyindex 8db85ab1f9..4efe8ca652 100644--- a/saleor/site/migrations/0001_initial.py+++ b/saleor/site/migrations/0001_initial.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.3 on 2017-01-13 12:38from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0002_add_default_data.py b/saleor/site/migrations/0002_add_default_data.pyindex 2f91920bcc..bbd3a3a98d 100644--- a/saleor/site/migrations/0002_add_default_data.py+++ b/saleor/site/migrations/0002_add_default_data.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-01-27 11:41from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0003_sitesettings_description.py b/saleor/site/migrations/0003_sitesettings_description.pyindex 6335d37927..5484259fd7 100644--- a/saleor/site/migrations/0003_sitesettings_description.py+++ b/saleor/site/migrations/0003_sitesettings_description.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-08 12:42from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0004_auto_20170221_0426.py b/saleor/site/migrations/0004_auto_20170221_0426.pyindex 36f16d27ed..dfef2ae35e 100644--- a/saleor/site/migrations/0004_auto_20170221_0426.py+++ b/saleor/site/migrations/0004_auto_20170221_0426.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.10.5 on 2017-02-21 10:26from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0005_auto_20170906_0556.py b/saleor/site/migrations/0005_auto_20170906_0556.pyindex f91d6919ce..f98b25e519 100644--- a/saleor/site/migrations/0005_auto_20170906_0556.py+++ b/saleor/site/migrations/0005_auto_20170906_0556.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.4 on 2017-09-06 10:56from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0006_auto_20171025_0454.py b/saleor/site/migrations/0006_auto_20171025_0454.pyindex 6464e880ac..d1027d2c89 100644--- a/saleor/site/migrations/0006_auto_20171025_0454.py+++ b/saleor/site/migrations/0006_auto_20171025_0454.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-10-25 09:54from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0007_auto_20171027_0856.py b/saleor/site/migrations/0007_auto_20171027_0856.pyindex 11badbe67c..d6f243e8af 100644--- a/saleor/site/migrations/0007_auto_20171027_0856.py+++ b/saleor/site/migrations/0007_auto_20171027_0856.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-10-27 13:56from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0008_auto_20171027_0856.py b/saleor/site/migrations/0008_auto_20171027_0856.pyindex b73482ca22..451969c30d 100644--- a/saleor/site/migrations/0008_auto_20171027_0856.py+++ b/saleor/site/migrations/0008_auto_20171027_0856.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-10-27 13:56from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0009_auto_20171109_0849.py b/saleor/site/migrations/0009_auto_20171109_0849.pyindex 694d6166df..d94270d66b 100644--- a/saleor/site/migrations/0009_auto_20171109_0849.py+++ b/saleor/site/migrations/0009_auto_20171109_0849.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-09 14:49from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0010_auto_20171113_0958.py b/saleor/site/migrations/0010_auto_20171113_0958.pyindex e0fdd62061..3c9c2b0e60 100644--- a/saleor/site/migrations/0010_auto_20171113_0958.py+++ b/saleor/site/migrations/0010_auto_20171113_0958.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2017-11-13 15:58from __future__ import unicode_literalsdiff --git a/saleor/site/migrations/0011_auto_20180108_0814.py b/saleor/site/migrations/0011_auto_20180108_0814.pyindex 4ff688b0cd..933a83d04e 100644--- a/saleor/site/migrations/0011_auto_20180108_0814.py+++ b/saleor/site/migrations/0011_auto_20180108_0814.py@@ -1,4 +1,3 @@-# -*- coding: utf-8 -*-# Generated by Django 1.11.5 on 2018-01-08 14:14from __future__ import unicode_literalsdiff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex f62ddb4f60..1840c98a7f 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -28,7 +28,7 @@ from PIL import Imagefrom prices import Money, TaxedMoney, fixed_discountfrom ..account.models import Address, StaffNotificationRecipient, User-from ..app.models import App, AppExtension, AppInstallation, AppToken+from ..app.models import App, AppExtension, AppInstallationfrom ..app.types import AppExtensionMount, AppTypefrom ..attribute import AttributeEntityType, AttributeInputType, AttributeTypefrom ..attribute.models import (@@ -144,7 +144,6 @@ class CaptureQueriesContext(BaseCaptureQueriesContext):@propertydef captured_queries(self):- # flake8: noqabase_queries = self.connection.queries[self.initial_queries : self.final_queries]@@ -3595,7 +3594,6 @@ def order_line_with_one_allocation(def checkout_line_with_reservation_in_many_stocks(customer_user, variant_with_many_stocks, checkout):- address = customer_user.default_billing_address.get_copy()variant = variant_with_many_stocksstocks = variant.stocks.all().order_by("pk")checkout_line = checkout.lines.create(@@ -3629,7 +3627,6 @@ def checkout_line_with_reservation_in_many_stocks(def checkout_line_with_one_reservation(customer_user, variant_with_many_stocks, checkout):- address = customer_user.default_billing_address.get_copy()variant = variant_with_many_stocksstocks = variant.stocks.all().order_by("pk")checkout_line = checkout.lines.create(@@ -4247,7 +4244,7 @@ def order_with_line_without_inventory_tracking(gross = Money(amount=net.amount * Decimal(1.23), currency=currency)quantity = 3unit_price = TaxedMoney(net=net, gross=gross)- line = order.lines.create(+ order.lines.create(product_name=str(variant.product),variant_name=str(variant),product_sku=variant.sku,@@ -5481,7 +5478,9 @@ def other_description_json():{"key": "","data": {- "text": "A GRAPHQL-FIRST <b>ECOMMERCE</b> PLATFORM FOR PERFECTIONISTS",+ "text": (+ "A GRAPHQL-FIRST <b>ECOMMERCE</b> PLATFORM FOR PERFECTIONISTS"+ ),},"text": "A GRAPHQL-FIRST ECOMMERCE PLATFORM FOR PERFECTIONISTS","type": "header-two",diff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.pyindex 77552528a9..955868c743 100644--- a/saleor/warehouse/models.py+++ b/saleor/warehouse/models.py@@ -62,7 +62,7 @@ class WarehouseQueryset(models.QuerySet):def applicable_for_click_and_collect_no_quantity_check(self, lines_qs: QuerySet[CheckoutLine], channel_id: int):- """Return the queryset of a `Warehouse` which are applicable for click and collect.+ """Return Warehouses which support click and collect.Note this method does not check stocks quantity for given `CheckoutLine`s.This method should be used only if stocks quantity will be checked in further@@ -83,7 +83,7 @@ class WarehouseQueryset(models.QuerySet):def applicable_for_click_and_collect(self, lines_qs: QuerySet[CheckoutLine], channel_id: int) -> QuerySet["Warehouse"]:- """Return the queryset of a `Warehouse` which are applicable for click and collect.+ """Return Warehouses which support click and collect.Note additional check of stocks quantity for given `CheckoutLine`s.For `WarehouseClickAndCollect.LOCAL` all `CheckoutLine`s must be available fromdiff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex f930b0b2fd..18f4d35f6e 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -212,10 +212,10 @@ def generate_order_lines_payload(lines: Iterable[OrderLine]):lines,fields=line_fields,extra_dict_data={- "product_variant_id": (lambda l: l.product_variant_id),- "total_price_net_amount": (lambda l: l.total_price.net.amount),- "total_price_gross_amount": (lambda l: l.total_price.gross.amount),- "allocations": (lambda l: prepare_order_lines_allocations_payload(l)),+ "product_variant_id": (lambda line: line.product_variant_id),+ "total_price_net_amount": (lambda line: line.total_price.net.amount),+ "total_price_gross_amount": (lambda line: line.total_price.gross.amount),+ "allocations": (lambda line: prepare_order_lines_allocations_payload(line)),},)@@ -1307,24 +1307,28 @@ def _generate_order_lines_payload_for_tax_calculation(lines: Iterable[OrderLine]lines,fields=("product_name", "variant_name", "quantity"),extra_dict_data={- "variant_id": (lambda l: l.product_variant_id),- "full_name": (lambda l: l.variant.display_product() if l.variant else None),+ "variant_id": (lambda line: line.product_variant_id),+ "full_name": (+ lambda line: line.variant.display_product() if line.variant else None+ ),"product_metadata": (- lambda l: l.variant.product.metadata if l.variant else {}+ lambda line: line.variant.product.metadata if line.variant else {}),"product_type_metadata": (- lambda l: l.variant.product.product_type.metadata if l.variant else {}+ lambda line: line.variant.product.product_type.metadata+ if line.variant+ else {}),"charge_taxes": (- lambda l: l.variant.product.charge_taxes if l.variant else None+ lambda line: line.variant.product.charge_taxes if line.variant else None),- "sku": (lambda l: l.product_sku),+ "sku": (lambda line: line.product_sku),"unit_amount": (- lambda l: quantize_price(l.base_unit_price_amount, l.currency)+ lambda line: quantize_price(line.base_unit_price_amount, line.currency)),"total_amount": (- lambda l: quantize_price(- l.base_unit_price_amount * l.quantity, l.currency+ lambda line: quantize_price(+ line.base_unit_price_amount * line.quantity, line.currency)),},