Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Enable pygrep-hooks lint rules in Ruff (#16896)
Patryk Zawadzkib4324e723b76
diff --git a/pyproject.toml b/pyproject.tomlindex d2c0bfd5d9..cc7b21a7df 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -194,6 +194,7 @@ target-version = "py39""ISC001","ISC002","LOG",+ "PGH","PIE","PT","PYI",diff --git a/saleor/attribute/migrations/0034_assignedpageattributevalue_page_data_migration.py b/saleor/attribute/migrations/0034_assignedpageattributevalue_page_data_migration.pyindex 7ba6ba8a19..a5652814f3 100644--- a/saleor/attribute/migrations/0034_assignedpageattributevalue_page_data_migration.py+++ b/saleor/attribute/migrations/0034_assignedpageattributevalue_page_data_migration.py@@ -43,7 +43,7 @@ def update_page_assignment():FROM attribute_assignedpageattribute AS apaWHERE av.id IN (SELECT id FROM limited)AND av.assignment_id = apa.id;- """, # noqa+ """,[PAGE_BATCH_SIZE],)diff --git a/saleor/attribute/migrations/0036_assignedproductattributevalue_product_data_migration.py b/saleor/attribute/migrations/0036_assignedproductattributevalue_product_data_migration.pyindex 376c9fc22f..7330d86b0c 100644--- a/saleor/attribute/migrations/0036_assignedproductattributevalue_product_data_migration.py+++ b/saleor/attribute/migrations/0036_assignedproductattributevalue_product_data_migration.py@@ -41,7 +41,7 @@ def update_product_assignment():FOR UPDATELIMIT %s);- """, # noqa+ """,[PRODUCT_BATCH_SIZE],)diff --git a/saleor/attribute/tests/test_utils.py b/saleor/attribute/tests/test_utils.pyindex 4fb576cd0c..9f830f7415 100644--- a/saleor/attribute/tests/test_utils.py+++ b/saleor/attribute/tests/test_utils.py@@ -57,7 +57,7 @@ def test_associate_attribute_to_non_product_instance(color_attribute):associate_attribute_values_to_instance(instance,{attribute.id: [value]},- ) # noqa+ )assert exc.value.args == ("ProductType is unsupported",)diff --git a/saleor/attribute/utils.py b/saleor/attribute/utils.pyindex 0d6857fa91..fc787a358f 100644--- a/saleor/attribute/utils.py+++ b/saleor/attribute/utils.py@@ -106,7 +106,7 @@ def _associate_attribute_to_instance("attribute_id__in": list(attr_val_map.keys()),"product_type_id": prod_type_id,}- instance_attrs_ids = instance_attribute_model.objects.filter( # type: ignore+ instance_attrs_ids = instance_attribute_model.objects.filter( # type: ignore[attr-defined]**attribute_filter).values_list("pk", flat=True)diff --git a/saleor/checkout/actions.py b/saleor/checkout/actions.pyindex c0a89a7227..8a9160cce4 100644--- a/saleor/checkout/actions.py+++ b/saleor/checkout/actions.py@@ -1,5 +1,4 @@import datetime-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional, cast@@ -81,7 +80,7 @@ def call_checkout_event(def _trigger_checkout_sync_webhooks(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],webhook_event_map: dict[str, set["Webhook"]],address: Optional["Address"] = None,):@@ -151,7 +150,7 @@ def call_checkout_info_event(manager: "PluginsManager",event_name: str,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"] = None,webhook_event_map: Optional[dict[str, set["Webhook"]]] = None,) -> None:diff --git a/saleor/checkout/base_calculations.py b/saleor/checkout/base_calculations.pyindex 36cf051979..4efa82825a 100644--- a/saleor/checkout/base_calculations.py+++ b/saleor/checkout/base_calculations.py@@ -6,7 +6,6 @@ taxes (Money instead of TaxedMoney). If you don't need pre-taxed prices use funcfrom calculations.py."""-from collections.abc import Iterablefrom typing import TYPE_CHECKING, Optionalfrom prices import Money@@ -96,7 +95,7 @@ def calculate_undiscounted_base_line_unit_price(def base_checkout_delivery_price(checkout_info: "CheckoutInfo",- lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ lines: Optional[list["CheckoutLineInfo"]] = None,include_voucher: bool = True,) -> Money:"""Calculate base (untaxed) price for any kind of delivery method."""@@ -122,7 +121,7 @@ def base_checkout_delivery_price(def base_checkout_undiscounted_delivery_price(checkout_info: "CheckoutInfo",- lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ lines: Optional[list["CheckoutLineInfo"]] = None,) -> Money:"""Calculate base (untaxed) undiscounted price for any kind of delivery method."""from .fetch import ShippingMethodInfo@@ -141,7 +140,7 @@ def base_checkout_undiscounted_delivery_price(def calculate_base_price_for_shipping_method(checkout_info: "CheckoutInfo",shipping_method_info: "ShippingMethodInfo",- lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ lines: Optional[list["CheckoutLineInfo"]] = None,) -> Money:"""Return checkout shipping price."""from .fetch import CheckoutLineInfo@@ -166,7 +165,7 @@ def calculate_base_price_for_shipping_method(def base_checkout_total(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],) -> Money:"""Return the total cost of the checkout.@@ -182,7 +181,7 @@ def base_checkout_total(def base_checkout_subtotal(- checkout_lines: Iterable["CheckoutLineInfo"],+ checkout_lines: list["CheckoutLineInfo"],channel: "Channel",currency: str,include_voucher: bool = True,@@ -206,7 +205,7 @@ def base_checkout_subtotal(def checkout_total(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],) -> Money:"""Return the total cost of the checkout including discounts and vouchers.@@ -234,7 +233,7 @@ def checkout_total(def apply_checkout_discount_on_checkout_line(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",line_total_price: Money,):@@ -267,7 +266,7 @@ def apply_checkout_discount_on_checkout_line(def _get_discounted_checkout_line_price(checkout_line_info: "CheckoutLineInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],line_total_price: Money,total_discount_amount: "Decimal",channel: "Channel",diff --git a/saleor/checkout/calculations.py b/saleor/checkout/calculations.pyindex 2bab750555..c8e60da060 100644--- a/saleor/checkout/calculations.py+++ b/saleor/checkout/calculations.py@@ -47,7 +47,7 @@ def checkout_shipping_price(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -74,7 +74,7 @@ def checkout_shipping_tax_rate(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,) -> Decimal:@@ -96,7 +96,7 @@ def checkout_subtotal(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -122,7 +122,7 @@ def checkout_subtotal(def calculate_checkout_total_with_gift_cards(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -145,7 +145,7 @@ def checkout_total(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -175,7 +175,7 @@ def checkout_line_total(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -204,7 +204,7 @@ def checkout_line_unit_price(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,@@ -234,7 +234,7 @@ def checkout_line_tax_rate(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,) -> Decimal:@@ -257,12 +257,12 @@ def checkout_line_tax_rate(def _fetch_checkout_prices_if_expired(checkout_info: "CheckoutInfo",manager: "PluginsManager",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"] = None,force_update: bool = False,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,pregenerated_subscription_payloads: Optional[dict] = None,-) -> tuple["CheckoutInfo", Iterable["CheckoutLineInfo"]]:+) -> tuple["CheckoutInfo", list["CheckoutLineInfo"]]:"""Fetch checkout prices with taxes.First calculate and apply all checkout prices with taxes separately,@@ -400,7 +400,7 @@ def _calculate_and_add_tax(checkout: "Checkout",manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],prices_entered_with_tax: bool,address: Optional["Address"] = None,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,@@ -457,7 +457,7 @@ def _call_plugin_or_tax_app(checkout: "Checkout",manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"] = None,pregenerated_subscription_payloads: Optional[dict] = None,):@@ -529,7 +529,7 @@ def _calculate_checkout_subtotal(lines, currency):def _apply_tax_data(checkout: "Checkout",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],tax_data: Optional[TaxData],) -> None:if not tax_data:@@ -564,7 +564,7 @@ def _apply_tax_data_from_plugins(checkout: "Checkout",manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],plugin_ids: Optional[list[str]] = None,) -> None:@@ -609,7 +609,7 @@ def _apply_tax_data_from_plugins(def _set_checkout_base_prices(checkout: "Checkout",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],) -> None:currency = checkout_info.checkout.currencysubtotal = zero_money(currency)@@ -650,7 +650,7 @@ def _set_checkout_base_prices(def fetch_checkout_data(checkout_info: "CheckoutInfo",manager: "PluginsManager",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"] = None,force_update: bool = False,checkout_transactions: Optional[Iterable["TransactionItem"]] = None,diff --git a/saleor/checkout/checkout_cleaner.py b/saleor/checkout/checkout_cleaner.pyindex 02597033af..5b10901bfb 100644--- a/saleor/checkout/checkout_cleaner.py+++ b/saleor/checkout/checkout_cleaner.py@@ -23,7 +23,7 @@ if TYPE_CHECKING:def clean_checkout_shipping(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],error_code: Union[type[CheckoutErrorCode],type[PaymentErrorCode],@@ -85,7 +85,7 @@ def clean_billing_address(def clean_checkout_payment(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],error_code: type[CheckoutErrorCode],last_payment: Optional[payment_models.Payment],):@@ -122,7 +122,7 @@ def _validate_gift_cards(checkout: Checkout):def validate_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],unavailable_variant_pks: Iterable[int],manager: "PluginsManager",):diff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.pyindex 9d61cad7b5..1d94b48346 100644--- a/saleor/checkout/complete_checkout.py+++ b/saleor/checkout/complete_checkout.py@@ -175,7 +175,7 @@ def _process_shipping_data_for_order(base_shipping_price: Money,shipping_price: TaxedMoney,manager: "PluginsManager",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],) -> dict[str, Any]:"""Fetch, process and return shipping data from checkout."""delivery_method_info = checkout_info.delivery_method_info@@ -234,7 +234,7 @@ def _process_user_data_for_order(checkout_info: "CheckoutInfo", manager):def _create_line_for_order(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",products_translation: dict[int, Optional[str]],variants_translation: dict[int, Optional[str]],@@ -430,7 +430,7 @@ def _get_sale_id(line_discounts: list[OrderLineDiscount]):def _create_lines_for_order(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],prices_entered_with_tax: bool,) -> Iterable[OrderLineInfo]:"""Create a lines for the given order.@@ -503,7 +503,7 @@ def _prepare_order_data(*,manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],prices_entered_with_tax: bool,) -> dict:"""Run checks and return all the data from a given checkout to create an order.@@ -618,7 +618,7 @@ def _prepare_order_data(def _create_order(*,checkout_info: "CheckoutInfo",- checkout_lines: Iterable["CheckoutLineInfo"],+ checkout_lines: list["CheckoutLineInfo"],order_data: dict,user: User,app: Optional["App"],@@ -761,7 +761,7 @@ def _create_order(def _prepare_checkout(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],redirect_url,):"""Prepare checkout object to complete the checkout process."""@@ -797,7 +797,7 @@ def _prepare_checkout(def _prepare_checkout_with_transactions(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],redirect_url: Optional[str],):"""Prepare checkout object with transactions to complete the checkout process."""@@ -842,7 +842,7 @@ def _prepare_checkout_with_transactions(def _prepare_checkout_with_payment(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],redirect_url: Optional[str],payment: Optional[Payment],):@@ -865,7 +865,7 @@ def _prepare_checkout_with_payment(def _get_order_data(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],site_settings: "SiteSettings",) -> dict:"""Prepare data that will be converted to order and its lines."""@@ -939,7 +939,7 @@ def _process_payment(def complete_checkout_pre_payment_part(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],user,site_settings=None,redirect_url=None,@@ -985,7 +985,7 @@ def complete_checkout_pre_payment_part(def complete_checkout_post_payment_part(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],payment: Optional[Payment],txn: Optional[Transaction],order_data,@@ -1491,7 +1491,7 @@ def assign_checkout_user(def complete_checkout(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],payment_data: dict[Any, Any],store_source: bool,user: Optional["User"],@@ -1570,7 +1570,7 @@ def complete_checkout(def complete_checkout_with_transaction(manager: "PluginsManager",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],user: Optional["User"],app: Optional["App"],redirect_url: Optional[str] = None,@@ -1746,7 +1746,7 @@ def complete_checkout_with_payment(def _reserve_stocks_without_availability_check(checkout_info: CheckoutInfo,- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],):"""Add additional temporary reservation for stock.diff --git a/saleor/checkout/fetch.py b/saleor/checkout/fetch.pyindex f9e6a4ef0f..5972fa9c08 100644--- a/saleor/checkout/fetch.py+++ b/saleor/checkout/fetch.py@@ -5,7 +5,6 @@ from functools import cached_property, singledispatchfrom typing import (TYPE_CHECKING,Any,- Callable,Optional,Union,)@@ -68,7 +67,7 @@ class CheckoutInfo:shipping_address: Optional["Address"]tax_configuration: "TaxConfiguration"discounts: list["CheckoutDiscount"]- lines: Iterable[CheckoutLineInfo]+ lines: list[CheckoutLineInfo]shipping_channel_listings: list["ShippingMethodChannelListing"]shipping_method: Optional["ShippingMethod"] = Nonecollection_point: Optional["Warehouse"] = None@@ -110,7 +109,7 @@ class CheckoutInfo:from ..webhook.transport.shipping import convert_to_app_id_with_identifierfrom .utils import get_external_shipping_id- delivery_method: Optional[Union[ShippingMethodData, Warehouse, Callable]] = None+ delivery_method: Optional[Union[ShippingMethodData, Warehouse]] = Noneif self.shipping_method:# Find listing for the currently selected shipping method@@ -126,19 +125,17 @@ class CheckoutInfo:)elif external_shipping_method_id := get_external_shipping_id(self.checkout):-- def _resolve_external_method():- methods = {method.id: method for method in self.all_shipping_methods}- if method := methods.get(external_shipping_method_id):- return method+ methods = {method.id: method for method in self.all_shipping_methods}+ if method := methods.get(external_shipping_method_id):+ delivery_method = method+ else:new_shipping_method_id = convert_to_app_id_with_identifier(external_shipping_method_id)if new_shipping_method_id is None:- return None- return methods.get(new_shipping_method_id)-- delivery_method = _resolve_external_method+ delivery_method = None+ else:+ delivery_method = methods.get(new_shipping_method_id)else:delivery_method = self.collection_point@@ -274,11 +271,9 @@ class CollectionPointInfo(DeliveryMethodBase):@singledispatchdef get_delivery_method_info(- delivery_method: Optional[Union["ShippingMethodData", "Warehouse", Callable]],+ delivery_method: Optional[Union["ShippingMethodData", "Warehouse"]],address: Optional["Address"] = None,) -> DeliveryMethodBase:- if callable(delivery_method):- delivery_method = delivery_method()if delivery_method is None:return DeliveryMethodBase()if isinstance(delivery_method, ShippingMethodData):@@ -299,7 +294,7 @@ def fetch_checkout_lines(skip_recalculation: bool = False,voucher: Optional["Voucher"] = None,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,-) -> tuple[Iterable[CheckoutLineInfo], Iterable[int]]:+) -> tuple[list[CheckoutLineInfo], list[int]]:"""Fetch checkout lines as CheckoutLineInfo objects."""from ..discount.utils.voucher import apply_voucher_to_linefrom .utils import get_voucher_for_checkout@@ -450,7 +445,7 @@ def _get_product_channel_listing(def fetch_checkout_info(checkout: "Checkout",- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],manager: "PluginsManager",shipping_channel_listings: Optional[Iterable["ShippingMethodChannelListing"]@@ -498,7 +493,7 @@ def fetch_checkout_info(def get_valid_internal_shipping_method_list_for_checkout_info(checkout_info: "CheckoutInfo",shipping_address: Optional["Address"],- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],shipping_channel_listings: Iterable[ShippingMethodChannelListing],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,) -> list["ShippingMethodData"]:@@ -569,7 +564,7 @@ def update_delivery_method_lists_for_checkout_info(shipping_method: Optional["ShippingMethod"],collection_point: Optional["Warehouse"],shipping_address: Optional["Address"],- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],shipping_channel_listings: Iterable[ShippingMethodChannelListing],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):@@ -594,7 +589,7 @@ def update_delivery_method_lists_for_checkout_info(def find_checkout_line_info(- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],line_id: "UUID",) -> "CheckoutLineInfo":"""Return checkout line info from lines parameter.diff --git a/saleor/checkout/problems.py b/saleor/checkout/problems.pyindex 323cbe7cc1..1ad0759b23 100644--- a/saleor/checkout/problems.py+++ b/saleor/checkout/problems.py@@ -39,7 +39,7 @@ CHECKOUT_LINE_PK_TYPE = strdef get_insufficient_stock_lines(- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],variant_stock_map: dict[tuple[VARIANT_ID,@@ -109,7 +109,7 @@ def line_is_not_available(def get_not_available_lines(- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],product_channel_listings_map: dict[tuple[PRODUCT_ID,@@ -129,7 +129,7 @@ def get_not_available_lines(def get_checkout_lines_problems(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],variant_stock_map: dict[tuple[VARIANT_ID,diff --git a/saleor/checkout/tests/test_checkout.py b/saleor/checkout/tests/test_checkout.pyindex 3b78bf6b85..616cb8741e 100644--- a/saleor/checkout/tests/test_checkout.py+++ b/saleor/checkout/tests/test_checkout.py@@ -1251,7 +1251,7 @@ def test_get_discount_for_checkout_shipping_voucher_not_applicable(quantity=total_quantity,spec=Checkout,channel=channel_USD,- get_value_from_private_metadata=Mock(return_value=None),+ metadata_storage=Mock(get_value_from_private_metadata=Mock(return_value=None)),)voucher = Voucher.objects.create(diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 40e9d1576e..8e0b35fa7d 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -67,6 +67,7 @@ if TYPE_CHECKING:from measurement.measures import Weightfrom ..account.models import Address+ from ..core.models import ModelWithMetadatafrom ..core.pricing.interface import LineInfofrom ..order.models import Order, OrderLinefrom .fetch import CheckoutInfo, CheckoutLineInfo@@ -77,7 +78,7 @@ PRIVATE_META_APP_SHIPPING_ID = "external_app_shipping_id"def invalidate_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],manager: "PluginsManager",*,recalculate_discount: bool = True,@@ -93,7 +94,7 @@ def invalidate_checkout(def recalculate_checkout_discounts(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],manager: "PluginsManager",):"""Recalculate checkout discounts.@@ -230,7 +231,7 @@ def add_variant_to_checkout(return checkout-def calculate_checkout_quantity(lines: Iterable["CheckoutLineInfo"]):+def calculate_checkout_quantity(lines: list["CheckoutLineInfo"]):return sum([line_info.line.quantity for line_info in lines])@@ -398,7 +399,7 @@ def change_billing_address_in_checkout(checkout, address) -> list[str]:def change_shipping_address_in_checkout(checkout_info: "CheckoutInfo",address: "Address",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],manager: "PluginsManager",shipping_channel_listings: Iterable["ShippingMethodChannelListing"],):@@ -432,7 +433,7 @@ def change_shipping_address_in_checkout(def _get_shipping_voucher_discount_for_checkout(voucher: Voucher,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],):"""Calculate discount value for a voucher of shipping type."""@@ -488,7 +489,7 @@ def get_voucher_discount_for_checkout(manager: PluginsManager,voucher: Voucher,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],) -> Money:"""Calculate discount value depending on voucher and discount types.@@ -520,7 +521,7 @@ def get_voucher_discount_for_checkout(def _get_products_voucher_discount(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],voucher,):"""Calculate products discount value for a voucher, depending on its type."""@@ -606,7 +607,7 @@ def check_voucher_for_checkout(voucher: Voucher,manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],):checkout = checkout_info.checkoutaddress = checkout_info.shipping_address or checkout_info.billing_address@@ -628,7 +629,7 @@ def check_voucher_for_checkout(def recalculate_checkout_discount(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],):"""Recalculate `checkout.discount` based on the voucher.@@ -684,7 +685,7 @@ def recalculate_checkout_discount(def add_promo_code_to_checkout(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],promo_code: str,):"""Add gift card or voucher data to checkout.@@ -713,7 +714,7 @@ def add_promo_code_to_checkout(def add_voucher_code_to_checkout(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],voucher_code: str,):"""Add voucher data to checkout by code.@@ -739,7 +740,7 @@ def add_voucher_code_to_checkout(def add_voucher_to_checkout(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],voucher: Voucher,voucher_code: VoucherCode,):@@ -839,7 +840,7 @@ def remove_voucher_from_checkout(checkout: Checkout):def get_valid_internal_shipping_methods_for_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],subtotal: "Money",shipping_channel_listings: Iterable["ShippingMethodChannelListing"],country_code: Optional[str] = None,@@ -876,7 +877,7 @@ def get_valid_internal_shipping_methods_for_checkout(def get_valid_collection_points_for_checkout(- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],channel_id: int,quantity_check: bool = True,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,@@ -933,7 +934,7 @@ def clear_delivery_method(checkout_info: "CheckoutInfo"):def is_fully_paid(manager: PluginsManager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):"""Check if provided payment methods cover the checkout's total amount.@@ -968,12 +969,12 @@ def activate_payments(payment_ids: list[int]) -> None:Payment.objects.filter(id__in=payment_ids).update(is_active=True)-def is_shipping_required(lines: Iterable["CheckoutLineInfo"]):+def is_shipping_required(lines: list["CheckoutLineInfo"]):"""Check if shipping is required for given checkout lines."""return any(line_info.product_type.is_shipping_required for line_info in lines)-def validate_variants_in_checkout_lines(lines: Iterable["CheckoutLineInfo"]):+def validate_variants_in_checkout_lines(lines: list["CheckoutLineInfo"]):variants_listings_map = {line.variant.id: line.channel_listing for line in lines}not_available_variants = [@@ -1006,11 +1007,12 @@ def set_external_shipping_id(checkout: Checkout, app_shipping_id: str):def get_external_shipping_id(container: Union["Checkout", "Order"]):- if type(container) is Checkout:- container = get_checkout_metadata(container)- return container.get_value_from_private_metadata( # type:ignore- PRIVATE_META_APP_SHIPPING_ID- )+ metadata_object: ModelWithMetadata+ if isinstance(container, Checkout):+ metadata_object = get_checkout_metadata(container)+ else:+ metadata_object = container+ return metadata_object.get_value_from_private_metadata(PRIVATE_META_APP_SHIPPING_ID)def delete_external_shipping_id(checkout: Checkout, save: bool = False):@@ -1036,7 +1038,7 @@ def get_checkout_metadata(checkout: "Checkout"):return CheckoutMetadata(checkout=checkout)-def calculate_checkout_weight(lines: Iterable["CheckoutLineInfo"]) -> "Weight":+def calculate_checkout_weight(lines: list["CheckoutLineInfo"]) -> "Weight":weights = zero_weight()for checkout_line_info in lines:variant = checkout_line_info.variant@@ -1075,7 +1077,7 @@ def get_address_for_checkout_taxes(def checkout_info_for_logs(checkout_info: "CheckoutInfo",- checkout_lines_info: Iterable["CheckoutLineInfo"],+ checkout_lines_info: list["CheckoutLineInfo"],):checkout = checkout_info.checkoutcheckout_id = graphene.Node.to_global_id("Checkout", checkout.pk)@@ -1136,7 +1138,7 @@ def checkout_info_for_logs(def log_unknown_discount_reason(order_lines: Iterable["OrderLine"],checkout_info: "CheckoutInfo",- checkout_lines_info: Iterable["CheckoutLineInfo"],+ checkout_lines_info: list["CheckoutLineInfo"],logger,):prices_entered_with_tax = checkout_info.tax_configuration.prices_entered_with_taxdiff --git a/saleor/core/models.py b/saleor/core/models.pyindex a9b0315a98..c215d56b08 100644--- a/saleor/core/models.py+++ b/saleor/core/models.py@@ -2,7 +2,7 @@ import datetimefrom collections.abc import Iterablefrom typing import Any, TypeVar-from django.contrib.postgres.indexes import GinIndex+from django.contrib.postgres.indexes import GinIndex, PostgresIndexfrom django.core.files.base import ContentFilefrom django.db import models, transactionfrom django.db.models import F, JSONField, Max, Q@@ -84,7 +84,7 @@ class ModelWithMetadata(models.Model):metadata = JSONField(blank=True, null=True, default=dict, encoder=CustomJsonEncoder)class Meta:- indexes = [+ indexes: list[PostgresIndex] = [GinIndex(fields=["private_metadata"], name="%(class)s_p_meta_idx"),GinIndex(fields=["metadata"], name="%(class)s_meta_idx"),]diff --git a/saleor/core/payments.py b/saleor/core/payments.pyindex 0fd3a5e6b8..e9c6b1f354 100644--- a/saleor/core/payments.py+++ b/saleor/core/payments.py@@ -1,5 +1,4 @@from abc import ABC, abstractmethod-from collections.abc import Iterablefrom typing import TYPE_CHECKING, Optionalfrom ..checkout.fetch import CheckoutInfo, CheckoutLineInfo@@ -20,7 +19,7 @@ class PaymentInterface(ABC):self,currency: Optional[str] = None,checkout_info: Optional["CheckoutInfo"] = None,- checkout_lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ checkout_lines: Optional[list["CheckoutLineInfo"]] = None,channel_slug: Optional[str] = None,active_only: bool = True,) -> list["PaymentGateway"]:diff --git a/saleor/discount/utils/checkout.py b/saleor/discount/utils/checkout.pyindex 2a94b2ad28..91d1223147 100644--- a/saleor/discount/utils/checkout.py+++ b/saleor/discount/utils/checkout.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom typing import TYPE_CHECKINGfrom django.conf import settings@@ -28,7 +27,7 @@ if TYPE_CHECKING:def create_or_update_discount_objects_from_promotion_for_checkout(checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):create_checkout_line_discount_objects_for_catalogue_promotions(lines_info)@@ -38,7 +37,7 @@ def create_or_update_discount_objects_from_promotion_for_checkout(def create_checkout_line_discount_objects_for_catalogue_promotions(- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],):discount_data = prepare_line_discount_objects_for_catalogue_promotions(lines_info)if not discount_data or not lines_info:@@ -56,7 +55,7 @@ def create_checkout_line_discount_objects_for_catalogue_promotions(with transaction.atomic():# Protect against potential thread race. CheckoutLine object can have only# single catalogue discount applied.- checkout_id = lines_info[0].line.checkout_id # type: ignore[index]+ checkout_id = lines_info[0].line.checkout_id_checkout_lock = list(Checkout.objects.filter(pk=checkout_id).select_for_update(of=(["self"])))@@ -89,7 +88,7 @@ def create_checkout_line_discount_objects_for_catalogue_promotions(def create_checkout_discount_objects_for_order_promotions(checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],*,save: bool = False,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,@@ -156,7 +155,7 @@ def _set_checkout_base_prices(checkout_info, lines_info):def _clear_checkout_discount(- checkout_info: "CheckoutInfo", lines_info: Iterable["CheckoutLineInfo"], save: bool+ checkout_info: "CheckoutInfo", lines_info: list["CheckoutLineInfo"], save: bool):delete_gift_line(checkout_info.checkout, lines_info)if checkout_info.discounts:diff --git a/saleor/discount/utils/manual_discount.py b/saleor/discount/utils/manual_discount.pyindex 9259a421cf..ae0dae1671 100644--- a/saleor/discount/utils/manual_discount.py+++ b/saleor/discount/utils/manual_discount.py@@ -1,6 +1,6 @@from decimal import ROUND_HALF_UP, Decimalfrom functools import partial-from typing import Optional, Union+from typing import Optional, TypeVarfrom prices import Money, TaxedMoney, fixed_discount, percentage_discount@@ -9,13 +9,15 @@ from ...core.taxes import zero_moneyfrom .. import DiscountValueTypefrom ..models import OrderDiscount+T = TypeVar("T", Money, TaxedMoney)+def apply_discount_to_value(value: Decimal,value_type: Optional[str],currency: str,- price_to_discount: Union[Money, TaxedMoney],-):+ price_to_discount: T,+) -> T:"""Calculate the price based on the provided values."""if value_type == DiscountValueType.PERCENTAGE:discount_method = percentage_discountdiff --git a/saleor/discount/utils/order.py b/saleor/discount/utils/order.pyindex 9702fb51cc..c67df6ff17 100644--- a/saleor/discount/utils/order.py+++ b/saleor/discount/utils/order.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING@@ -31,7 +30,7 @@ if TYPE_CHECKING:def create_or_update_discount_objects_for_order(order: "Order",- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):create_or_update_discount_objects_from_promotion_for_order(@@ -46,7 +45,7 @@ def create_or_update_discount_objects_for_order(def create_or_update_discount_objects_from_promotion_for_order(order: "Order",- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):create_order_line_discount_objects_for_catalogue_promotions(lines_info)@@ -58,14 +57,14 @@ def create_or_update_discount_objects_from_promotion_for_order(def create_order_line_discount_objects_for_catalogue_promotions(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):discount_data = prepare_line_discount_objects_for_catalogue_promotions(lines_info)create_order_line_discount_objects(lines_info, discount_data)def create_order_line_discount_objects(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],discount_data: tuple[list[dict],list[OrderLineDiscount],@@ -88,7 +87,7 @@ def create_order_line_discount_objects(with transaction.atomic():# Protect against potential thread race. OrderLine object can have only# single catalogue discount applied.- order_id = lines_info[0].line.order_id # type: ignore[index]+ order_id = lines_info[0].line.order_id_order_lock = list(Order.objects.filter(id=order_id).select_for_update(of=(["self"])))@@ -126,7 +125,7 @@ def create_order_line_discount_objects(def _copy_unit_discount_data_to_order_line(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):for line_info in lines_info:if discounts := line_info.discounts:@@ -152,7 +151,7 @@ def _copy_unit_discount_data_to_order_line(def _update_base_unit_price_amount_for_catalogue_promotion(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):for line_info in lines_info:line = line_info.line@@ -165,7 +164,7 @@ def _update_base_unit_price_amount_for_catalogue_promotion(def create_order_discount_objects_for_order_promotions(order: "Order",- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):# If voucher is set or manual discount applied, then skip order promotions@@ -197,7 +196,7 @@ def create_order_discount_objects_for_order_promotions(return-def _set_order_base_prices(order: Order, lines_info: Iterable["EditableOrderLineInfo"]):+def _set_order_base_prices(order: Order, lines_info: list["EditableOrderLineInfo"]):"""Set base order prices that includes only catalogue discounts."""lines = [line_info.line for line_info in lines_info]subtotal = base_order_subtotal(order, lines)@@ -220,7 +219,7 @@ def _set_order_base_prices(order: Order, lines_info: Iterable["EditableOrderLine@allow_writer()def _clear_order_discount(order_or_checkout: Order,- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):with transaction.atomic():delete_gift_line(order_or_checkout, lines_info)diff --git a/saleor/discount/utils/promotion.py b/saleor/discount/utils/promotion.pyindex 8f297dcb8f..107adf1170 100644--- a/saleor/discount/utils/promotion.py+++ b/saleor/discount/utils/promotion.py@@ -157,7 +157,7 @@ def get_product_discount_on_promotion(@overloaddef prepare_line_discount_objects_for_catalogue_promotions(- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],) -> tuple[list[dict], list["CheckoutLineDiscount"], list["CheckoutLineDiscount"], list[str]]: ...@@ -165,7 +165,7 @@ def prepare_line_discount_objects_for_catalogue_promotions(@overloaddef prepare_line_discount_objects_for_catalogue_promotions(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],) -> tuple[list[dict], list["OrderLineDiscount"], list["OrderLineDiscount"], list[str]]: ...@@ -509,12 +509,12 @@ def _get_available_for_purchase_variant_ids(@allow_writer()def delete_gift_line(order_or_checkout: Union[Checkout, Order],- lines_info: Iterable[Union["CheckoutLineInfo", "EditableOrderLineInfo"]],+ lines_info: Union[list["CheckoutLineInfo"], list["EditableOrderLineInfo"]],):if gift_line_infos := [line for line in lines_info if line.line.is_gift]:order_or_checkout.lines.filter(is_gift=True).delete() # type: ignore[misc]for gift_line_info in gift_line_infos:- lines_info.remove(gift_line_info) # type: ignore[attr-defined]+ lines_info.remove(gift_line_info) # type: ignore[arg-type]def create_gift_line(order_or_checkout: Union[Checkout, Order], variant_id: int):@@ -766,7 +766,7 @@ def update_rule_variant_relation(def create_discount_objects_for_order_promotions(order_or_checkout: Union[Checkout, Order],- lines_info: Union[Iterable["EditableOrderLineInfo"], Iterable["CheckoutLineInfo"]],+ lines_info: Union[list["EditableOrderLineInfo"], list["CheckoutLineInfo"]],subtotal: Money,channel: "Channel",country: str,@@ -843,7 +843,7 @@ def create_discount_objects_for_order_promotions(@allow_writer()def _handle_order_promotion(order_or_checkout: Union[Order, Checkout],- lines_info: Union[Iterable["EditableOrderLineInfo"], Iterable["CheckoutLineInfo"]],+ lines_info: Union[list["EditableOrderLineInfo"], list["CheckoutLineInfo"]],discount_object_defaults: dict,rule_info: VariantPromotionRuleInfo,):@@ -872,7 +872,7 @@ def _handle_order_promotion(@allow_writer()def _handle_gift_reward(order_or_checkout: Union[Order, Checkout],- lines_info: Union[Iterable["EditableOrderLineInfo"], Iterable["CheckoutLineInfo"]],+ lines_info: Union[list[EditableOrderLineInfo], list[CheckoutLineInfo]],gift_listing: ProductVariantChannelListing,channel: "Channel",discount_object_defaults: dict,@@ -926,11 +926,12 @@ def _handle_gift_reward("voucher": None,"voucher_code": None,}+ gift_line_info: CheckoutLineInfo | EditableOrderLineInfoif isinstance(order_or_checkout, Checkout):gift_line_info = CheckoutLineInfo(**init_values)else:- gift_line_info = EditableOrderLineInfo(**init_values) # type: ignore- lines_info.append(gift_line_info) # type: ignore+ gift_line_info = EditableOrderLineInfo(**init_values)+ lines_info.append(gift_line_info) # type: ignore[arg-type]else:line_info = next(line_info for line_info in lines_info if line_info.line.pk == line.iddiff --git a/saleor/discount/utils/voucher.py b/saleor/discount/utils/voucher.pyindex f3a8f71d33..d8dc1fa419 100644--- a/saleor/discount/utils/voucher.py+++ b/saleor/discount/utils/voucher.py@@ -1,4 +1,4 @@-from collections.abc import Iterable+from collections.abc import Iterable, Sequencefrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional, cast@@ -165,7 +165,7 @@ def get_active_voucher_code(voucher, channel_slug):def apply_voucher_to_line(voucher_info: "VoucherInfo",- lines_info: Iterable["LineInfo"],+ lines_info: Sequence["LineInfo"],):"""Attach voucher to valid checkout or order lines info.@@ -239,7 +239,7 @@ def validate_voucher_for_checkout(manager: "PluginsManager",voucher: "Voucher",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],):from ...checkout import base_calculationsfrom ...checkout.utils import calculate_checkout_quantity@@ -419,7 +419,7 @@ def create_or_update_line_discount_objects_from_voucher(lines_info):# TODO (SHOPX-912): share the method with checkoutdef prepare_line_discount_objects_for_voucher(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):line_discounts_to_create_inputs: list[dict] = []line_discounts_to_update: list[OrderLineDiscount] = []@@ -540,7 +540,7 @@ def calculate_line_discount_amount_from_voucher(def _reduce_base_unit_price_for_voucher_discount(- lines_info: Iterable["EditableOrderLineInfo"],+ lines_info: list["EditableOrderLineInfo"],):for line_info in lines_info:line = line_info.linediff --git a/saleor/giftcard/utils.py b/saleor/giftcard/utils.pyindex d196cdb8a1..2cdebfb50e 100644--- a/saleor/giftcard/utils.py+++ b/saleor/giftcard/utils.py@@ -161,7 +161,7 @@ def fulfill_gift_card_lines(@traced_atomic_transaction()def gift_cards_create(order: "Order",- gift_card_lines_info: Iterable["GiftCardLineData"],+ gift_card_lines_info: list["GiftCardLineData"],settings: "SiteSettings",requestor_user: Optional["User"],app: Optional["App"],@@ -275,7 +275,7 @@ def assign_user_gift_cards(user):def is_gift_card_expired(gift_card: GiftCard):"""Return True when gift card expiry date pass."""today = timezone.now().date()- return bool(gift_card.expiry_date) and gift_card.expiry_date < today # type: ignore+ return bool(gift_card.expiry_date) and gift_card.expiry_date < today # type: ignore[operator]def get_user_gift_cards(user: "User") -> "QuerySet":diff --git a/saleor/graphql/account/mutations/account/account_request_deletion.py b/saleor/graphql/account/mutations/account/account_request_deletion.pyindex 04f9e2acde..de612a773c 100644--- a/saleor/graphql/account/mutations/account/account_request_deletion.py+++ b/saleor/graphql/account/mutations/account/account_request_deletion.py@@ -1,3 +1,4 @@+from typing import castfrom urllib.parse import urlencodeimport graphene@@ -5,6 +6,7 @@ from django.core.exceptions import ValidationErrorfrom .....account import notificationsfrom .....account.error_codes import AccountErrorCode+from .....account.models import Userfrom .....core.tokens import account_delete_token_generatorfrom .....core.utils.url import prepare_url, validate_storefront_urlfrom .....permission.auth_filters import AuthorizationFilters@@ -57,7 +59,7 @@ class AccountRequestDeletion(BaseMutation):def perform_mutation( # type: ignore[override]cls, _root, info: ResolveInfo, /, *, channel=None, redirect_url):- user = info.context.user+ user = cast(User, info.context.user)try:validate_storefront_url(redirect_url)except ValidationError as e:@@ -68,7 +70,7 @@ class AccountRequestDeletion(BaseMutation):channel, error_class=AccountErrorCode, allow_replica=False).slugmanager = get_plugin_manager_promise(info.context).get()- token = account_delete_token_generator.make_token(user) # type: ignore+ token = account_delete_token_generator.make_token(user)# Notifications will be deprecated in the futurenotifications.send_account_delete_confirmation_notification(diff --git a/saleor/graphql/account/mutations/authentication/utils.py b/saleor/graphql/account/mutations/authentication/utils.pyindex 3928377cd2..d67d4f81e3 100644--- a/saleor/graphql/account/mutations/authentication/utils.py+++ b/saleor/graphql/account/mutations/authentication/utils.py@@ -3,7 +3,7 @@ import datetimeimport jwtfrom django.conf import settingsfrom django.core.exceptions import ValidationError-from django.middleware.csrf import ( # type: ignore+from django.middleware.csrf import ( # type: ignore[attr-defined]_get_new_csrf_string,_mask_cipher_secret,_unmask_cipher_token,diff --git a/saleor/graphql/attribute/utils.py b/saleor/graphql/attribute/utils.pyindex fea1f60b83..05aa1bb3f5 100644--- a/saleor/graphql/attribute/utils.py+++ b/saleor/graphql/attribute/utils.py@@ -746,7 +746,7 @@ class AttributeAssignmentMixin:for ref in attr_values.references:name = getattr(ref, field_name)if attribute.entity_type == AttributeEntityType.PRODUCT_VARIANT:- name = f"{ref.product.name}: {name}" # type: ignore+ name = f"{ref.product.name}: {name}" # type: ignore[union-attr]reference_list.append((@@ -754,7 +754,7 @@ class AttributeAssignmentMixin:{"attribute": attribute,"slug": slugify(- unidecode(f"{instance.id}_{ref.id}") # type: ignore+ unidecode(f"{instance.id}_{ref.id}") # type: ignore[union-attr]),"defaults": {"name": name},attr_value_field: ref,diff --git a/saleor/graphql/checkout/dataloaders/checkout_infos.py b/saleor/graphql/checkout/dataloaders/checkout_infos.pyindex 73d5f4c09c..f881eea5ff 100644--- a/saleor/graphql/checkout/dataloaders/checkout_infos.py+++ b/saleor/graphql/checkout/dataloaders/checkout_infos.py@@ -1,4 +1,5 @@from collections import defaultdict+from collections.abc import Sequencefrom promise import Promise@@ -210,7 +211,9 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader[str, CheckoutInfo]):)-class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader[str, list[CheckoutLineInfo]]):+class CheckoutLinesInfoByCheckoutTokenLoader(+ DataLoader[str, Sequence[CheckoutLineInfo]]+):context_key = "checkoutlinesinfo_by_checkout"def batch_load(self, keys):diff --git a/saleor/graphql/checkout/mutations/checkout_complete.py b/saleor/graphql/checkout/mutations/checkout_complete.pyindex 897bad898d..70daccdee1 100644--- a/saleor/graphql/checkout/mutations/checkout_complete.py+++ b/saleor/graphql/checkout/mutations/checkout_complete.py@@ -1,5 +1,3 @@-from collections.abc import Iterable-import graphenefrom django.core.exceptions import ValidationError@@ -172,7 +170,7 @@ class CheckoutComplete(BaseMutation, I18nMixin):def validate_checkout_addresses(cls,checkout_info: CheckoutInfo,- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],):"""Validate checkout addresses.diff --git a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.pyindex 1b3313c16d..1f6a7393c4 100644--- a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py+++ b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom typing import Optionalimport graphene@@ -237,7 +236,7 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):cls,manager,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],*,shipping_method: Optional[ShippingMethod],external_shipping_method: Optional[shipping_interface.ShippingMethodData],diff --git a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.pyindex 0395e732a1..899dab1dc2 100644--- a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py+++ b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom typing import TYPE_CHECKINGimport graphene@@ -90,7 +89,7 @@ class CheckoutShippingAddressUpdate(AddressMetadataMixin, BaseMutation, I18nMixidef process_checkout_lines(cls,info,- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],country: str,channel_slug: str,delivery_method_info: "DeliveryMethodBase",diff --git a/saleor/graphql/checkout/mutations/utils.py b/saleor/graphql/checkout/mutations/utils.pyindex 5d98bd7502..0294dafd7a 100644--- a/saleor/graphql/checkout/mutations/utils.py+++ b/saleor/graphql/checkout/mutations/utils.py@@ -71,7 +71,7 @@ class CheckoutLineData:def clean_delivery_method(checkout_info: "CheckoutInfo",- lines: Iterable[CheckoutLineInfo],+ lines: list[CheckoutLineInfo],method: Optional[Union[shipping_interface.ShippingMethodData,@@ -111,14 +111,14 @@ def _is_external_shipping_valid(checkout_info: "CheckoutInfo") -> bool:def update_checkout_external_shipping_method_if_invalid(- checkout_info: "CheckoutInfo", lines: Iterable[CheckoutLineInfo]+ checkout_info: "CheckoutInfo", lines: list[CheckoutLineInfo]):if not _is_external_shipping_valid(checkout_info):delete_external_shipping_id(checkout_info.checkout, save=True)def update_checkout_shipping_method_if_invalid(- checkout_info: "CheckoutInfo", lines: Iterable[CheckoutLineInfo]+ checkout_info: "CheckoutInfo", lines: list[CheckoutLineInfo]):quantity = calculate_checkout_quantity(lines)diff --git a/saleor/graphql/context.py b/saleor/graphql/context.pyindex 572f486b20..11ea9aad4e 100644--- a/saleor/graphql/context.py+++ b/saleor/graphql/context.py@@ -56,10 +56,10 @@ def get_user(request: SaleorContext) -> Optional[User]:def set_auth_on_context(request: SaleorContext):if hasattr(request, "app") and request.app:- request.user = SimpleLazyObject(lambda: None) # type: ignore+ request.user = SimpleLazyObject(lambda: None) # type: ignore[assignment]returndef user():return get_user(request) or None- request.user = SimpleLazyObject(user) # type: ignore+ request.user = SimpleLazyObject(user) # type: ignore[assignment]diff --git a/saleor/graphql/core/__init__.py b/saleor/graphql/core/__init__.pyindex 48b7b5f59d..a6ff5d1bc4 100644--- a/saleor/graphql/core/__init__.py+++ b/saleor/graphql/core/__init__.py@@ -1,6 +1,6 @@import graphene-from . import fields # noqa+from . import fields # noqa: F401from .context import SaleorContext__all__ = ["SaleorContext"]diff --git a/saleor/graphql/core/connection.py b/saleor/graphql/core/connection.pyindex 2fe245077c..21f1213b10 100644--- a/saleor/graphql/core/connection.py+++ b/saleor/graphql/core/connection.py@@ -54,9 +54,9 @@ def from_global_cursor(cursor) -> list[str]:def get_field_value(instance: DjangoModel, field_name: str):"""Get field value for given field in filter format 'field__foreign_key_field'."""field_path = field_name.split("__")- attr = instance+ attr: Any = instancefor elem in field_path:- attr = getattr(attr, elem, None) # type:ignore+ attr = getattr(attr, elem, None)if callable(attr):return f"{attr()}"diff --git a/saleor/graphql/core/context.py b/saleor/graphql/core/context.pyindex 61e63576ff..062ff02b78 100644--- a/saleor/graphql/core/context.py+++ b/saleor/graphql/core/context.py@@ -60,7 +60,7 @@ def get_database_connection_name(context: SaleorContext) -> str:def setup_context_user(context: SaleorContext) -> None:if hasattr(context.user, "_wrapped") and (- context.user._wrapped is empty or context.user._wrapped is None # type: ignore+ context.user._wrapped is empty or context.user._wrapped is None # type: ignore[union-attr]):- context.user._setup() # type: ignore- context.user = context.user._wrapped # type: ignore+ context.user._setup() # type: ignore[union-attr]+ context.user = context.user._wrapped # type: ignore[union-attr]diff --git a/saleor/graphql/core/filters.py b/saleor/graphql/core/filters.pyindex a2b0e70049..864b173e7d 100644--- a/saleor/graphql/core/filters.py+++ b/saleor/graphql/core/filters.py@@ -218,27 +218,23 @@ class MetadataWhereFilterBase(WhereFilterSet):class WhereFilter(Filter):- def method(): # type: ignore+ @property+ def method(self):# Filter method needs to be lazily resolved, as it may be dependent on# the 'parent' FilterSet.+ return self._method- def fget(self):- return self._method+ @method.setter+ def method(self, value):+ self._method = value- def fset(self, value):- self._method = value+ # clear existing FilterMethod+ if isinstance(self.filter, WhereFilterMethod):+ del self.filter- # clear existing FilterMethod- if isinstance(self.filter, WhereFilterMethod):- del self.filter-- # override filter w/ FilterMethod.- if value is not None:- self.filter = WhereFilterMethod(self)-- return locals()-- method = property(**method()) # type: ignore+ # override filter w/ FilterMethod.+ if value is not None:+ self.filter = WhereFilterMethod(self) # type: ignore[method-assign]def filter(self, qs, value):if self.distinct:@@ -314,4 +310,4 @@ class GlobalIDWhereFilter(WhereFilter):_id = Noneif value is not None:_, _id = from_global_id(value)- return super(GlobalIDFilter, self).filter(qs, _id) # type: ignore+ return super(GlobalIDFilter, self).filter(qs, _id) # type: ignore[misc]diff --git a/saleor/graphql/discount/dataloaders.py b/saleor/graphql/discount/dataloaders.pyindex e103b07bf3..1a82a4f12f 100644--- a/saleor/graphql/discount/dataloaders.py+++ b/saleor/graphql/discount/dataloaders.py@@ -84,7 +84,7 @@ class UsedByVoucherIDLoader(DataLoader[int, int]):)vouchers_map: dict[int, int] = {}for voucher in vouchers:- vouchers_map[voucher.id] = voucher.max_used # type: ignore+ vouchers_map[voucher.id] = voucher.max_used # type: ignore[attr-defined]return [vouchers_map.get(voucher_id) for voucher_id in keys]diff --git a/saleor/graphql/discount/mutations/sale/sale_channel_listing_update.py b/saleor/graphql/discount/mutations/sale/sale_channel_listing_update.pyindex 949c1f4f5c..45345f45f0 100644--- a/saleor/graphql/discount/mutations/sale/sale_channel_listing_update.py+++ b/saleor/graphql/discount/mutations/sale/sale_channel_listing_update.py@@ -1,5 +1,5 @@from collections import defaultdict-from typing import cast+from typing import Any, Callable, castimport graphenefrom django.core.exceptions import ValidationError@@ -224,6 +224,8 @@ class SaleChannelListingUpdate(BaseChannelListingMutation):):add_channels = cleaned_input.get("add_channels", [])remove_channels = cleaned_input.get("remove_channels", [])+ func_arg: Any+ mark_as_dirty_func: Callable[[Any], None]if remove_channels and not add_channels:# In case of only removing the channels, we need to mark the product to be# recalculated.@@ -231,8 +233,8 @@ class SaleChannelListingUpdate(BaseChannelListingMutation):mark_as_dirty_func = mark_products_in_channels_as_dirtyfunc_arg = {int(channel_id): product_ids for channel_id in remove_channels}else:- mark_as_dirty_func = mark_catalogue_promotion_rules_as_dirty # type: ignore- func_arg = [promotion.pk] # type: ignore[assignment]+ mark_as_dirty_func = mark_catalogue_promotion_rules_as_dirty+ func_arg = [promotion.pk]with traced_atomic_transaction():cls.add_channels(promotion, rule, cleaned_input.get("add_channels", []))diff --git a/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py b/saleor/graphql/order/tests/benchmark/test_order_bulk_create.pyindex 98f0755451..c1604365cd 100644--- a/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py+++ b/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py@@ -6,7 +6,7 @@ from django.utils import timezonefrom ....discount.enums import DiscountValueTypeEnumfrom ....tests.utils import get_graphql_content-from ..mutations.test_order_bulk_create import ( # noqa F401+from ..mutations.test_order_bulk_create import ( # noqa: F401ORDER_BULK_CREATE,order_bulk_input,order_bulk_input_with_multiple_order_lines_and_fulfillments,@@ -20,7 +20,7 @@ def test_order_bulk_create(permission_manage_orders,permission_manage_orders_import,permission_manage_users,- order_bulk_input_with_multiple_order_lines_and_fulfillments, # noqa F881+ order_bulk_input_with_multiple_order_lines_and_fulfillments, # noqa: F811product_variant_list,customer_user,app,diff --git a/saleor/graphql/order/tests/integration/test_bulk_order.py b/saleor/graphql/order/tests/integration/test_bulk_order.pyindex 7ea79101e3..58674de139 100644--- a/saleor/graphql/order/tests/integration/test_bulk_order.py+++ b/saleor/graphql/order/tests/integration/test_bulk_order.py@@ -20,7 +20,7 @@ from ..mutations.test_draft_order_complete import DRAFT_ORDER_COMPLETE_MUTATIONfrom ..mutations.test_fulfillment_return_products import ORDER_FULFILL_RETURN_MUTATIONfrom ..mutations.test_order_bulk_create import (ORDER_BULK_CREATE,- order_bulk_input, # noqa F401+ order_bulk_input, # noqa: F401)from ..mutations.test_order_fulfill import ORDER_FULFILL_MUTATION@@ -30,7 +30,7 @@ def test_create_order_from_imported_draft_order(staff_api_client,permission_manage_orders_import,permission_group_manage_orders,- order_bulk_input, # noqa F881+ order_bulk_input, # noqa: F811product,channel_USD,):@@ -76,7 +76,7 @@ def test_fulfill_imported_order(staff_api_client,permission_manage_orders_import,permission_group_manage_orders,- order_bulk_input, # noqa F881+ order_bulk_input, # noqa: F811product,warehouse,channel_USD,@@ -140,7 +140,7 @@ def test_return_and_refund_imported_order(permission_manage_orders_import,permission_group_manage_orders,permission_manage_payments,- order_bulk_input, # noqa F881+ order_bulk_input, # noqa: F811product,warehouse,channel_USD,@@ -224,7 +224,7 @@ def test_filter_imported_orders(staff_api_client,permission_manage_orders_import,permission_group_manage_orders,- order_bulk_input, # noqa F881+ order_bulk_input, # noqa: F811product,channel_USD,):diff --git a/saleor/graphql/product/mutations/product/product_media_delete.py b/saleor/graphql/product/mutations/product/product_media_delete.pyindex 075e338c46..c7fbf72905 100644--- a/saleor/graphql/product/mutations/product/product_media_delete.py+++ b/saleor/graphql/product/mutations/product/product_media_delete.py@@ -30,7 +30,7 @@ class ProductMediaDelete(BaseMutation):cls, _root, info: ResolveInfo, /, *, id: str):media_obj = cls.get_node_or_error(info, id, only_type=ProductMedia)- product = models.Product.objects.get(pk=media_obj.product_id) # type: ignore+ product = models.Product.objects.get(pk=media_obj.product_id) # type: ignore[misc]media_id = media_obj.idmedia_obj.delete()media_obj.id = media_iddiff --git a/saleor/graphql/tests/test_context.py b/saleor/graphql/tests/test_context.pyindex 6c5d0b592a..858dc9424e 100644--- a/saleor/graphql/tests/test_context.py+++ b/saleor/graphql/tests/test_context.py@@ -4,6 +4,7 @@ import graphenefrom django.utils import timezonefrom ..context import clear_context, get_context_value+from ..core.dataloaders import DataLoaderfrom .utils import get_graphql_contentQUERY_ORDER_BY_ID = """@@ -48,7 +49,7 @@ def test_user_is_cached_on_request(def test_get_context_value_not_override_dataloaders_if_passed_already(rf):# givenrequest = rf.request()- dataloaders = {}+ dataloaders: dict[str, DataLoader] = {}dataloaders_id = id(dataloaders)request.dataloaders = dataloaders@@ -76,7 +77,7 @@ def test_get_context_value_uses_request_time_if_passed_already(rf):def test_clear_context(rf):# givencontext = get_context_value(rf.request())- context.dataloaders = {"key": "value"} # type: ignore+ context.dataloaders = {"key": NotImplemented}# whenclear_context(context)diff --git a/saleor/invoice/notifications.py b/saleor/invoice/notifications.pyindex 045928b657..7032f00f43 100644--- a/saleor/invoice/notifications.py+++ b/saleor/invoice/notifications.py@@ -31,7 +31,7 @@ def send_invoice(def _generate_payload():payload = {"invoice": get_invoice_payload(invoice),- "recipient_email": invoice.order.get_customer_email(), # type: ignore+ "recipient_email": invoice.order.get_customer_email(), # type: ignore[union-attr]"requester_user_id": to_global_id_or_none(staff_user),"requester_app_id": to_global_id_or_none(app) if app else None,**get_site_context(),diff --git a/saleor/order/actions.py b/saleor/order/actions.pyindex 0d7835a0c4..2706130b1e 100644--- a/saleor/order/actions.py+++ b/saleor/order/actions.py@@ -1,6 +1,5 @@import loggingfrom collections import defaultdict-from collections.abc import Iterablefrom copy import deepcopyfrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional, TypedDict@@ -1053,7 +1052,7 @@ def _increase_order_line_quantity(order_lines_info):def fulfill_order_lines(- order_lines_info: Iterable["OrderLineInfo"],+ order_lines_info: list["OrderLineInfo"],manager: "PluginsManager",allow_stock_to_be_exceeded: bool = False,):diff --git a/saleor/order/fetch.py b/saleor/order/fetch.pyindex 2e24bac2f4..891129d6e5 100644--- a/saleor/order/fetch.py+++ b/saleor/order/fetch.py@@ -30,7 +30,7 @@ class OrderInfo:customer_email: "str"channel: "Channel"payment: Optional["Payment"]- lines_data: Iterable["OrderLineInfo"]+ lines_data: list["OrderLineInfo"]@dataclassdiff --git a/saleor/order/notifications.py b/saleor/order/notifications.pyindex 4233f40285..9a688b9e01 100644--- a/saleor/order/notifications.py+++ b/saleor/order/notifications.py@@ -42,7 +42,7 @@ class AttributeData:def get_attribute_data_from_order_lines(lines: Iterable["OrderLine"]) -> AttributeData:- product_ids = {line.variant.product_id for line in lines if line.variant_id} # type: ignore+ product_ids = {line.variant.product_id for line in lines if line.variant_id} # type: ignore[union-attr]assigned_product_attribute_values = (AssignedProductAttributeValue.objects.using(settings.DATABASE_CONNECTION_REPLICA_NAME@@ -61,7 +61,7 @@ def get_attribute_data_from_order_lines(lines: Iterable["OrderLine"]) -> Attribu).in_bulk(attribute_value_ids)product_type_ids = {- line.variant.product.product_type_id # type: ignore+ line.variant.product.product_type_id # type: ignore[union-attr]for line in linesif line.variant_id}diff --git a/saleor/order/tasks.py b/saleor/order/tasks.pyindex 59f53a423f..dc5a3c5ae0 100644--- a/saleor/order/tasks.py+++ b/saleor/order/tasks.py@@ -197,7 +197,7 @@ def delete_expired_orders_task():~Exists(Payment.objects.filter(order=OuterRef("pk"))),expired_at__isnull=False,status=OrderStatus.EXPIRED,- expired_at__lte=now - F("delete_expired_orders_after"), # type:ignore+ expired_at__lte=now - F("delete_expired_orders_after"), # type:ignore[operator]))ids_batch = qs.values_list("pk", flat=True)[:DELETE_EXPIRED_ORDER_BATCH_SIZE]diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex 0dca192aa4..ebec05f8e6 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -89,7 +89,7 @@ def order_line_needs_automatic_fulfillment(line_data: OrderLineInfo) -> bool:return False-def order_needs_automatic_fulfillment(lines_data: Iterable["OrderLineInfo"]) -> bool:+def order_needs_automatic_fulfillment(lines_data: list["OrderLineInfo"]) -> bool:"""Check if order has digital products which should be automatically fulfilled."""for line_data in lines_data:if line_data.is_digital and order_line_needs_automatic_fulfillment(line_data):@@ -796,7 +796,7 @@ def create_order_discount_for_order():"""Add new order discount and update the prices."""- current_total = order.undiscounted_total+ current_total: TaxedMoney = order.undiscounted_totalcurrency = order.currencygross_total = apply_discount_to_value(@@ -810,7 +810,7 @@ def create_order_discount_for_order(value_type=value_type,value=value,reason=reason,- amount=new_amount, # type: ignore+ amount=new_amount, # type: ignore[misc]**kwargs,)return order_discountdiff --git a/saleor/page/tests/fixtures/__init__.py b/saleor/page/tests/fixtures/__init__.pyindex 49a330058a..82983b8eec 100644--- a/saleor/page/tests/fixtures/__init__.py+++ b/saleor/page/tests/fixtures/__init__.py@@ -1,3 +1,3 @@-from .page import * # noqa F403-from .page_type import * # noqa F403-from .page_translation import * # noqa F403+from .page import * # noqa: F403+from .page_translation import * # noqa: F403+from .page_type import * # noqa: F403diff --git a/saleor/payment/gateways/adyen/plugin.py b/saleor/payment/gateways/adyen/plugin.pyindex 6a390435ca..28b1eaf14f 100644--- a/saleor/payment/gateways/adyen/plugin.py+++ b/saleor/payment/gateways/adyen/plugin.py@@ -1,5 +1,4 @@import json-from collections.abc import Iterablefrom typing import Optionalfrom urllib.parse import urlencode, urljoin@@ -303,7 +302,7 @@ class AdyenGatewayPlugin(BasePlugin):self,currency: Optional[str],checkout_info: Optional["CheckoutInfo"],- checkout_lines: Optional[Iterable["CheckoutLineInfo"]],+ checkout_lines: Optional[list["CheckoutLineInfo"]],previous_value,) -> list["PaymentGateway"]:"""Fetch current configuration for given checkout.@@ -424,7 +423,7 @@ class AdyenGatewayPlugin(BasePlugin):return_url = prepare_url(params,build_absolute_uri(- f"/plugins/channel/{self.channel.slug}/" # type: ignore+ f"/plugins/channel/{self.channel.slug}/" # type: ignore[union-attr]f"{self.PLUGIN_ID}/additional-actions"),)@@ -765,10 +764,14 @@ class AdyenGatewayPlugin(BasePlugin):) -> "GatewayResponse":if not self.active:return previous_value++ if not payment_information.token:+ raise PaymentError("Cannot find a payment reference to void.")+request = request_for_payment_cancel(payment_information=payment_information,merchant_account=self.config.connection_params["merchant_account"],- token=payment_information.token, # type: ignore+ token=payment_information.token,)with opentracing.global_tracer().start_active_span("adyen.payment.cancel"diff --git a/saleor/payment/gateways/adyen/utils/common.py b/saleor/payment/gateways/adyen/utils/common.pyindex ad13d2920c..27f17edeab 100644--- a/saleor/payment/gateways/adyen/utils/common.py+++ b/saleor/payment/gateways/adyen/utils/common.py@@ -1,6 +1,5 @@import jsonimport logging-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Any, Callable, Optional@@ -338,7 +337,7 @@ def get_shopper_locale_value(country_code: str):def request_data_for_gateway_config(checkout_info: "CheckoutInfo",- lines: Optional[Iterable[CheckoutLineInfo]],+ lines: Optional[list[CheckoutLineInfo]],merchant_account,) -> dict[str, Any]:manager = get_plugins_manager(allow_replica=False)diff --git a/saleor/payment/gateways/adyen/webhooks.py b/saleor/payment/gateways/adyen/webhooks.pyindex bfe435833b..c67bdaf24d 100644--- a/saleor/payment/gateways/adyen/webhooks.py+++ b/saleor/payment/gateways/adyen/webhooks.py@@ -949,14 +949,14 @@ def validate_auth_user(headers: HttpHeaders, gateway_config: "GatewayConfig") ->username = gateway_config.connection_params["webhook_user"]password = gateway_config.connection_params["webhook_user_password"]auth_header: Optional[str] = headers.get("Authorization")- if not auth_header and not username:- return True- if auth_header and not username:+ if not auth_header:+ if not username:+ return Truereturn False- if not auth_header and username:+ if not username:return False- split_auth = auth_header.split(maxsplit=1) # type: ignore+ split_auth = auth_header.split(maxsplit=1)prefix = "BASIC"if len(split_auth) != 2 or split_auth[0].upper() != prefix:diff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.pyindex 4e0a9ec0ff..1311036f6b 100644--- a/saleor/payment/gateways/stripe/plugin.py+++ b/saleor/payment/gateways/stripe/plugin.py@@ -9,7 +9,7 @@ from django.http.request import split_domain_portfrom ....core.utils import get_domainfrom ....graphql.core.enums import PluginErrorCodefrom ....plugins.base_plugin import BasePlugin, ConfigurationTypeField-from ... import TransactionKind+from ... import PaymentError, TransactionKindfrom ...interface import (CustomerSource,GatewayConfig,@@ -233,7 +233,7 @@ class StripeGatewayPlugin(BasePlugin):payment_method_id=payment_method_id,metadata={**payment_information.payment_metadata,- "channel": self.channel.slug, # type: ignore+ "channel": self.channel.slug, # type: ignore[union-attr]"payment_id": payment_information.graphql_payment_id,},setup_future_usage=setup_future_usage,@@ -368,12 +368,14 @@ class StripeGatewayPlugin(BasePlugin):if not self.active:return previous_valuepayment_intent_id = payment_information.token+ if not payment_intent_id:+ raise PaymentError("Cannot find a payment reference to capture.")capture_amount = price_to_minor_unit(payment_information.amount, payment_information.currency)payment_intent, error = capture_payment_intent(api_key=self.config.connection_params["secret_api_key"],- payment_intent_id=payment_intent_id, # type: ignore+ payment_intent_id=payment_intent_id,amount_to_capture=capture_amount,)@@ -403,12 +405,14 @@ class StripeGatewayPlugin(BasePlugin):if not self.active:return previous_valuepayment_intent_id = payment_information.token+ if not payment_intent_id:+ raise PaymentError("Cannot find a payment reference to refund.")refund_amount = price_to_minor_unit(payment_information.amount, payment_information.currency)refund, error = refund_payment_intent(api_key=self.config.connection_params["secret_api_key"],- payment_intent_id=payment_intent_id, # type: ignore+ payment_intent_id=payment_intent_id,amount_to_refund=refund_amount,)@@ -433,10 +437,12 @@ class StripeGatewayPlugin(BasePlugin):if not self.active:return previous_valuepayment_intent_id = payment_information.token+ if not payment_intent_id:+ raise PaymentError("Cannot find a payment reference to void.")payment_intent, error = cancel_payment_intent(api_key=self.config.connection_params["secret_api_key"],- payment_intent_id=payment_intent_id, # type: ignore+ payment_intent_id=payment_intent_id,)raw_response = None@@ -528,7 +534,7 @@ class StripeGatewayPlugin(BasePlugin):if not webhook_id and not webhook_secret_data.get("value"):webhook = subscribe_webhook(api_key,- plugin_configuration.channel.slug, # type: ignore+ plugin_configuration.channel.slug, # type: ignore[arg-type,union-attr])if not webhook:diff --git a/saleor/plugins/apps.py b/saleor/plugins/apps.pyindex cbcdddec11..d1cb7113e0 100644--- a/saleor/plugins/apps.py+++ b/saleor/plugins/apps.py@@ -27,8 +27,8 @@ class PluginConfig(AppConfig):self.check_plugin_fields(["PLUGIN_ID"], plugin)- def check_plugin_fields(self, fields: list[str], plugin_class: "BasePlugin"):- name = plugin_class.__name__ # type: ignore+ def check_plugin_fields(self, fields: list[str], plugin_class: type["BasePlugin"]):+ name = plugin_class.__name__for field in fields:if not getattr(plugin_class, field, None):diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.pyindex c425eb4629..2977492acc 100644--- a/saleor/plugins/avatax/__init__.py+++ b/saleor/plugins/avatax/__init__.py@@ -1,7 +1,6 @@import datetimeimport jsonimport logging-from collections.abc import Iterablefrom dataclasses import dataclassfrom decimal import Decimalfrom typing import TYPE_CHECKING, Any, Optional, Union, cast@@ -199,7 +198,7 @@ def _validate_order(order: "Order") -> bool:def _validate_checkout(- checkout_info: "CheckoutInfo", lines: Iterable["CheckoutLineInfo"]+ checkout_info: "CheckoutInfo", lines: list["CheckoutLineInfo"]) -> bool:"""Validate the checkout object if it is ready to generate a request to avatax."""if not lines:@@ -284,7 +283,7 @@ def append_shipping_to_data(def generate_request_data_from_checkout_lines(checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],config: AvataxConfiguration,) -> list[dict[str, Union[str, int, bool, None]]]:data: list[dict[str, Union[str, int, bool, None]]] = []@@ -502,7 +501,7 @@ def generate_request_data(def generate_request_data_from_checkout(checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],config: AvataxConfiguration,transaction_token=None,transaction_type=TransactionType.ORDER,@@ -605,7 +604,7 @@ def get_cached_response_or_fetch(def get_checkout_tax_data(checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],config: AvataxConfiguration,) -> dict[str, Any]:data = generate_request_data_from_checkout(checkout_info, lines_info, config)diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.pyindex 9b461d9335..86971d0d0f 100644--- a/saleor/plugins/avatax/plugin.py+++ b/saleor/plugins/avatax/plugin.py@@ -217,7 +217,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_total(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],previous_value: TaxedMoney,) -> TaxedMoney:@@ -298,7 +298,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_shipping(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],previous_value: TaxedMoney,) -> TaxedMoney:@@ -316,7 +316,7 @@ class AvataxPlugin(BasePlugin):def preprocess_order_creation(self,checkout_info: "CheckoutInfo",- lines: Optional[Iterable["CheckoutLineInfo"]],+ lines: Optional[list["CheckoutLineInfo"]],previous_value: Any,):"""Ensure all the data is correct and we can proceed with creation of order.@@ -406,7 +406,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_line_total(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: TaxedMoney,@@ -458,7 +458,7 @@ class AvataxPlugin(BasePlugin):if currency == "JPY" and prices_entered_with_tax():if isinstance(base_value, SimpleLazyObject):- base_value = base_value._setupfunc() # type: ignore+ base_value = base_value._setupfunc() # type: ignore[attr-defined]line_gross = Money(base_value.amount - discount_amount, currency=currency@@ -471,7 +471,7 @@ class AvataxPlugin(BasePlugin):return TaxedMoney(net=line_net, gross=line_gross)if isinstance(base_value, SimpleLazyObject):- base_value = base_value._setupfunc() # type: ignore+ base_value = base_value._setupfunc() # type: ignore[attr-defined]return TaxedMoney(net=base_value, gross=base_value)def calculate_order_line_total(@@ -547,7 +547,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_line_unit_price(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: TaxedMoney,@@ -691,7 +691,7 @@ class AvataxPlugin(BasePlugin):def get_checkout_line_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: Decimal,@@ -730,7 +730,7 @@ class AvataxPlugin(BasePlugin):def get_checkout_shipping_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],previous_value: Decimal,):@@ -744,7 +744,7 @@ class AvataxPlugin(BasePlugin):def _get_checkout_tax_data(self,checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],base_value: Union[TaxedMoney, Decimal],):if self._skip_plugin(base_value):@@ -780,7 +780,7 @@ class AvataxPlugin(BasePlugin):def _set_checkout_tax_error(self,checkout_info: "CheckoutInfo",- lines_info: Iterable["CheckoutLineInfo"],+ lines_info: list["CheckoutLineInfo"],tax_error_message: str,) -> None:app_identifier = get_tax_app_identifier_for_checkout(checkout_info, lines_info)diff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.pyindex 28269367dc..cac4399ed0 100644--- a/saleor/plugins/base_plugin.py+++ b/saleor/plugins/base_plugin.py@@ -1,5 +1,4 @@from collections import defaultdict-from collections.abc import Iterablefrom copy import copyfrom dataclasses import dataclassfrom decimal import Decimal@@ -716,7 +715,7 @@ class BasePlugin:get_checkout_shipping_tax_rate: Callable[["CheckoutInfo",- Iterable["CheckoutLineInfo"],+ list["CheckoutLineInfo"],Union["Address", None],Any,],@@ -726,7 +725,7 @@ class BasePlugin:# Note: This method is deprecated in Saleor 3.20 and will be removed in Saleor 3.21.# Webhook-related functionality will be moved from the plugin to core modules.get_taxes_for_checkout: Callable[- ["CheckoutInfo", Iterable["CheckoutLineInfo"], str, Any, Optional[dict]],+ ["CheckoutInfo", list["CheckoutLineInfo"], str, Any, Optional[dict]],Optional["TaxData"],]@@ -1177,7 +1176,7 @@ class BasePlugin:preprocess_order_creation: Callable[["CheckoutInfo",- Union[Iterable["CheckoutLineInfo"], None],+ Union[list["CheckoutLineInfo"], None],Any,],Any,@@ -1698,7 +1697,7 @@ class BasePlugin:self,currency: Optional[str],checkout_info: Optional["CheckoutInfo"],- checkout_lines: Optional[Iterable["CheckoutLineInfo"]],+ checkout_lines: Optional[list["CheckoutLineInfo"]],previous_value,) -> list["PaymentGateway"]:payment_config = (@@ -1834,11 +1833,8 @@ class BasePlugin:else:fields_without_structure.append(configuration_field)- if fields_without_structure:- [- configuration.remove(field) # type: ignore- for field in fields_without_structure- ]+ for field in fields_without_structure:+ configuration.remove(field)@classmethoddef _update_configuration_structure(cls, configuration: PluginConfigurationType):diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex 618aae114f..f8f64b44fe 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -248,7 +248,9 @@ class PluginsManager(PaymentInterface):plugin_method = getattr(plugin, method_name, NotImplemented)if plugin_method == NotImplemented:return previous_value- returned_value = plugin_method(*args, **kwargs, previous_value=previous_value) # type:ignore+ if not callable(plugin_method):+ raise ValueError(f"Method {method_name} is not callable")+ returned_value = plugin_method(*args, **kwargs, previous_value=previous_value)if returned_value == NotImplemented:return previous_valuereturn returned_value@@ -279,7 +281,7 @@ class PluginsManager(PaymentInterface):def calculate_checkout_total(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],plugin_ids: Optional[list[str]] = None,) -> TaxedMoney:@@ -313,7 +315,7 @@ class PluginsManager(PaymentInterface):def calculate_checkout_subtotal(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],plugin_ids: Optional[list[str]] = None,) -> TaxedMoney:@@ -337,7 +339,7 @@ class PluginsManager(PaymentInterface):def calculate_checkout_shipping(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],plugin_ids: Optional[list[str]] = None,) -> TaxedMoney:@@ -407,7 +409,7 @@ class PluginsManager(PaymentInterface):def get_checkout_shipping_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],shipping_price: TaxedMoney,plugin_ids: Optional[list[str]] = None,@@ -441,7 +443,7 @@ class PluginsManager(PaymentInterface):def calculate_checkout_line_total(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],plugin_ids: Optional[list[str]] = None,@@ -517,7 +519,7 @@ class PluginsManager(PaymentInterface):def calculate_checkout_line_unit_price(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],plugin_ids: Optional[list[str]] = None,@@ -597,7 +599,7 @@ class PluginsManager(PaymentInterface):def get_checkout_line_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],price: TaxedMoney,@@ -681,7 +683,7 @@ class PluginsManager(PaymentInterface):def preprocess_order_creation(self,checkout_info: "CheckoutInfo",- lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ lines: Optional[list["CheckoutLineInfo"]] = None,):default_value = Nonereturn self.__run_method_on_plugins(@@ -2518,7 +2520,7 @@ class PluginsManager(PaymentInterface):self,currency: Optional[str] = None,checkout_info: Optional["CheckoutInfo"] = None,- checkout_lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ checkout_lines: Optional[list["CheckoutLineInfo"]] = None,channel_slug: Optional[str] = None,active_only: bool = True,) -> list["PaymentGateway"]:@@ -2803,7 +2805,7 @@ class PluginsManager(PaymentInterface):self, plugin_id: str, data: dict, request: SaleorContext) -> dict:"""Handle authentication request."""- default_value = {} # type: ignore+ default_value: dict = {}plugin = self.get_plugin(plugin_id)return self.__run_method_on_single_plugin(plugin, "external_authentication_url", default_value, data, requestdiff --git a/saleor/plugins/openid_connect/plugin.py b/saleor/plugins/openid_connect/plugin.pyindex 3ef725fae9..87163dc387 100644--- a/saleor/plugins/openid_connect/plugin.py+++ b/saleor/plugins/openid_connect/plugin.py@@ -1,5 +1,5 @@import logging-from typing import Optional+from typing import Optional, castfrom authlib.common.errors import AuthlibBaseErrorfrom django.core import signing@@ -391,7 +391,8 @@ class OpenIDConnectPlugin(BasePlugin):refresh_token = data.get("refreshToken") or refresh_tokenvalidate_refresh_token(refresh_token, data)- saleor_refresh_token = jwt_decode(refresh_token) # type: ignore+ refresh_token = cast(str, refresh_token)+ saleor_refresh_token = jwt_decode(refresh_token)token_endpoint = self.config.token_urltry:token_data = self.oauth.refresh_token(diff --git a/saleor/plugins/openid_connect/utils.py b/saleor/plugins/openid_connect/utils.pyindex 6446f65386..f3d368c132 100644--- a/saleor/plugins/openid_connect/utils.py+++ b/saleor/plugins/openid_connect/utils.py@@ -399,11 +399,12 @@ def get_or_create_user_from_payload(if not user_email:raise AuthenticationError("Missing user's email.")- sub = payload.get("sub")+ sub: str | None = payload.get("sub")get_kwargs = {"private_metadata__contains": {oidc_metadata_key: sub}}if not sub:get_kwargs = {"email": user_email}logger.warning("Missing sub section in OIDC payload")+ raise AuthenticationError("Missing subject identifier.")defaults_create = {"is_active": True,@@ -414,7 +415,7 @@ def get_or_create_user_from_payload("private_metadata": {oidc_metadata_key: sub},"password": make_password(None),}- cache_key = oidc_metadata_key + ":" + str(sub)+ cache_key = oidc_metadata_key + ":" + subuser_id = cache.get(cache_key)if user_id:get_kwargs = {"id": user_id}@@ -448,7 +449,7 @@ def get_or_create_user_from_payload(user_email=user_email,user_first_name=defaults_create["first_name"],user_last_name=defaults_create["last_name"],- sub=sub, # type: ignore+ sub=sub,last_login=last_login,)diff --git a/saleor/plugins/sendgrid/plugin.py b/saleor/plugins/sendgrid/plugin.pyindex 6a8433d0a8..7c36113bc9 100644--- a/saleor/plugins/sendgrid/plugin.py+++ b/saleor/plugins/sendgrid/plugin.py@@ -247,7 +247,7 @@ class SendgridEmailPlugin(BasePlugin):configuration = {item["name"]: item["value"] for item in self.configuration}- event_task, event_template = EVENT_MAP.get(event) # type: ignore+ event_task, event_template = EVENT_MAP.get(event) # type: ignore[arg-type,misc]template_id = configuration.get(event_template)if not template_id:# the empty fields means that we should not send an email for this event.diff --git a/saleor/plugins/tests/sample_plugins.py b/saleor/plugins/tests/sample_plugins.pyindex defbe10777..75d01dc6be 100644--- a/saleor/plugins/tests/sample_plugins.py+++ b/saleor/plugins/tests/sample_plugins.py@@ -1,5 +1,4 @@from collections import defaultdict-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Any, Optional, Union@@ -115,7 +114,7 @@ class PluginSample(BasePlugin):def calculate_checkout_line_total(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: TaxedMoney,@@ -143,7 +142,7 @@ class PluginSample(BasePlugin):def calculate_checkout_line_unit_price(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: TaxedMoney,@@ -255,7 +254,7 @@ class PluginSample(BasePlugin):def get_checkout_line_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",address: Optional["Address"],previous_value: Decimal,@@ -275,7 +274,7 @@ class PluginSample(BasePlugin):def get_checkout_shipping_tax_rate(self,checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],address: Optional["Address"],previous_value: Decimal,):diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.pyindex 07af8b103d..9d6d01e15c 100644--- a/saleor/plugins/webhook/plugin.py+++ b/saleor/plugins/webhook/plugin.py@@ -246,7 +246,7 @@ class WebhookPlugin(BasePlugin):)def trigger_webhooks_async(self, *args, **kwargs):- return trigger_webhooks_async(*args, **kwargs, allow_replica=self.allow_replica) # type: ignore+ return trigger_webhooks_async(*args, **kwargs, allow_replica=self.allow_replica) # type: ignore[misc]def account_confirmed(self, user: "User", previous_value: None) -> None:if not self.active:@@ -3157,7 +3157,7 @@ class WebhookPlugin(BasePlugin):self,currency: Optional[str],checkout_info: Optional["CheckoutInfo"],- checkout_lines: Optional[Iterable["CheckoutLineInfo"]],+ checkout_lines: Optional[list["CheckoutLineInfo"]],previous_value,**kwargs,) -> list["PaymentGateway"]:diff --git a/saleor/product/migrations/0102_migrate_data_enterprise_grade_attributes.py b/saleor/product/migrations/0102_migrate_data_enterprise_grade_attributes.pyindex 6ac512e0d8..471324bea6 100644--- a/saleor/product/migrations/0102_migrate_data_enterprise_grade_attributes.py+++ b/saleor/product/migrations/0102_migrate_data_enterprise_grade_attributes.py@@ -11,7 +11,7 @@ def ensure_attribute_slugs_are_unique_or_fix(apps, schema_editor):Instead of being unique within a product type, attributes' slug are now globallyunique. For that, we look for duplicate slugs and rename them with a new suffix."""- Attribute = apps.get_model("product", "Attribute") # noqa+ Attribute = apps.get_model("product", "Attribute")non_unique_slugs = (Attribute.objects.values_list("slug", flat=True).annotate(slug_count=Count("slug"))diff --git a/saleor/product/search.py b/saleor/product/search.pyindex a86132144f..edf3862c46 100644--- a/saleor/product/search.py+++ b/saleor/product/search.py@@ -128,10 +128,10 @@ def generate_attributes_search_vector_value("""product_attributes = product.product_type.attributeproduct.all()- attributes = []- for product_attribute in product_attributes:- attributes.append(product_attribute.attribute) # type: ignore- attributes = attributes[: settings.PRODUCT_MAX_INDEXED_ATTRIBUTES]+ attributes = [+ product_attribute.attribute # type: ignore[attr-defined]+ for product_attribute in product_attributes+ ][: settings.PRODUCT_MAX_INDEXED_ATTRIBUTES]assigned_values = product.attributevalues.all()diff --git a/saleor/settings.py b/saleor/settings.pyindex 1370a1b1ab..183aea2d66 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -704,7 +704,7 @@ OBSERVABILITY_BUFFER_TIMEOUT = datetime.timedelta()if OBSERVABILITY_ACTIVE:CELERY_BEAT_SCHEDULE["observability-reporter"] = {- "task": "saleor.webhook.transport.asynchronous.transport.observability_reporter_task", # noqa+ "task": "saleor.webhook.transport.asynchronous.transport.observability_reporter_task","schedule": OBSERVABILITY_REPORT_PERIOD,"options": {"expires": OBSERVABILITY_REPORT_PERIOD.total_seconds()},}@@ -890,7 +890,7 @@ PRODUCT_MAX_INDEXED_VARIANTS = 1000# Patch SubscriberExecutionContext class from `graphql-core-legacy` package# to fix bug causing not returning errors for subscription queries.-executor.SubscriberExecutionContext = PatchedSubscriberExecutionContext # type: ignore+executor.SubscriberExecutionContext = PatchedSubscriberExecutionContext # type: ignore[assignment,misc]patch_executor()diff --git a/saleor/shipping/migrations/0024_shippingmethodzipcoderule.py b/saleor/shipping/migrations/0024_shippingmethodzipcoderule.pyindex 8e6f4524b3..e293fe5067 100644--- a/saleor/shipping/migrations/0024_shippingmethodzipcoderule.py+++ b/saleor/shipping/migrations/0024_shippingmethodzipcoderule.py@@ -35,6 +35,6 @@ class Migration(migrations.Migration):],options={"unique_together": {("shipping_method", "start", "end")},- }, # noqa+ },),]diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 0c1f53956f..9af4e57f3e 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional, Union@@ -177,9 +176,7 @@ class ShippingMethodQueryset(models.QuerySet["ShippingMethod"]):price: Money,shipping_address: Optional["Address"] = None,country_code: Optional[str] = None,- lines: Union[- Iterable["CheckoutLineInfo"], Iterable["OrderLineInfo"], None- ] = None,+ lines: Union[list["CheckoutLineInfo"], list["OrderLineInfo"], None] = None,):if not shipping_address:return Nonediff --git a/saleor/tax/calculations/checkout.py b/saleor/tax/calculations/checkout.pyindex 4b2a012c25..8c5f0a8eda 100644--- a/saleor/tax/calculations/checkout.py+++ b/saleor/tax/calculations/checkout.py@@ -1,4 +1,3 @@-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Optional@@ -22,7 +21,7 @@ if TYPE_CHECKING:def update_checkout_prices_with_flat_rates(checkout: "Checkout",checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],prices_entered_with_tax: bool,address: Optional["Address"] = None,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,@@ -83,7 +82,7 @@ def update_checkout_prices_with_flat_rates(def calculate_checkout_shipping(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],tax_rate: Decimal,prices_entered_with_tax: bool,) -> TaxedMoney:@@ -98,7 +97,7 @@ def calculate_checkout_shipping(def calculate_checkout_line_total(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],checkout_line_info: "CheckoutLineInfo",tax_rate: Decimal,prices_entered_with_tax: bool,diff --git a/saleor/tax/utils.py b/saleor/tax/utils.pyindex d7eda9e718..b4685d7967 100644--- a/saleor/tax/utils.py+++ b/saleor/tax/utils.py@@ -136,7 +136,7 @@ def get_tax_app_identifier_for_order(order: "Order"):def get_tax_configuration_for_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,) -> tuple["TaxConfiguration", Optional["TaxConfigurationPerCountry"]]:tax_configuration = checkout_info.tax_configuration@@ -160,7 +160,7 @@ def get_tax_configuration_for_checkout(def get_charge_taxes_for_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):"""Get charge_taxes value for checkout."""@@ -172,7 +172,7 @@ def get_charge_taxes_for_checkout(def get_tax_calculation_strategy_for_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):"""Get tax_calculation_strategy value for checkout."""@@ -184,7 +184,7 @@ def get_tax_calculation_strategy_for_checkout(def get_tax_app_identifier_for_checkout(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,):"""Get tax_app_id value for checkout."""diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex bd1eeac493..283061c8dc 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -50,7 +50,7 @@ from .utils import dummy_editorjsclass CaptureQueriesContext(BaseCaptureQueriesContext):- IGNORED_QUERIES = settings.PATTERNS_IGNORED_IN_QUERY_CAPTURES # type: ignore+ IGNORED_QUERIES = settings.PATTERNS_IGNORED_IN_QUERY_CAPTURES # type: ignore[misc]@propertydef captured_queries(self):diff --git a/saleor/tests/settings.py b/saleor/tests/settings.pyindex 8183e06479..fb65b81b39 100644--- a/saleor/tests/settings.py+++ b/saleor/tests/settings.py@@ -9,7 +9,7 @@ from django.utils.functional import SimpleLazyObject# without this line pytest will start sending traces to Jaeger agent.os.environ["JAEGER_AGENT_HOST"] = ""-from ..settings import * # noqa+from ..settings import * # noqa: F403def lazy_re_compile(regex, flags=0):diff --git a/saleor/tests/utils.py b/saleor/tests/utils.pyindex e93bb3ace3..b876346aec 100644--- a/saleor/tests/utils.py+++ b/saleor/tests/utils.py@@ -52,7 +52,7 @@ def prepare_test_db_connections():https://docs.djangoproject.com/en/4.2/topics/testing/advanced/#testing-primary-replica-configurations"""replica = settings.DATABASE_CONNECTION_REPLICA_NAME- connections[replica] = FakeDbReplicaConnection(connections[replica]) # type: ignore+ connections[replica] = FakeDbReplicaConnection(connections[replica]) # type: ignore[assignment]def dummy_editorjs(text, json_format=False):diff --git a/saleor/thumbnail/views.py b/saleor/thumbnail/views.pyindex fb2b792c88..607452da92 100644--- a/saleor/thumbnail/views.py+++ b/saleor/thumbnail/views.py@@ -97,11 +97,11 @@ def handle_thumbnail(try:if object_type in UUID_IDENTIFIABLE_TYPES:- instance = model_data.model.objects.using( # type: ignore+ instance = model_data.model.objects.using( # type: ignore[misc]settings.DATABASE_CONNECTION_REPLICA_NAME).get(uuid=pk)else:- instance = model_data.model.objects.using( # type: ignore+ instance = model_data.model.objects.using( # type: ignore[misc]settings.DATABASE_CONNECTION_REPLICA_NAME).get(id=pk)except ObjectDoesNotExist:diff --git a/saleor/warehouse/availability.py b/saleor/warehouse/availability.pyindex 41e87434ec..1e26ece131 100644--- a/saleor/warehouse/availability.py+++ b/saleor/warehouse/availability.py@@ -146,7 +146,7 @@ def check_stock_and_preorder_quantity_bulk(global_quantity_limit: Optional[int],delivery_method_info: Optional["DeliveryMethodBase"] = None,additional_filter_lookup: Optional[dict[str, Any]] = None,- existing_lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ existing_lines: Optional[list["CheckoutLineInfo"]] = None,replace: bool = False,check_reservations: bool = False,):@@ -238,7 +238,7 @@ def check_stock_quantity_bulk(global_quantity_limit: Optional[int],delivery_method_info: Optional["DeliveryMethodBase"] = None,additional_filter_lookup: Optional[dict[str, Any]] = None,- existing_lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ existing_lines: Optional[list["CheckoutLineInfo"]] = None,replace=False,check_reservations: bool = False,database_connection_name: str = settings.DATABASE_CONNECTION_DEFAULT_NAME,@@ -355,7 +355,7 @@ def _get_variants_channel_availability_info(variants_global_allocations = {variant_id: sum(- channel_listing.preorder_quantity_allocated # type: ignore+ channel_listing.preorder_quantity_allocated # type: ignore[attr-defined]for channel_listing in channel_listings)for variant_id, channel_listings in variant_channels.items()@@ -445,7 +445,7 @@ def check_preorder_threshold_bulk(quantities: Iterable[int],channel_slug: str,global_quantity_limit: Optional[int],- existing_lines: Optional[Iterable["CheckoutLineInfo"]] = None,+ existing_lines: Optional[list["CheckoutLineInfo"]] = None,replace: bool = False,check_reservations: bool = False,):diff --git a/saleor/warehouse/management.py b/saleor/warehouse/management.pyindex 6387729396..c7fad090ad 100644--- a/saleor/warehouse/management.py+++ b/saleor/warehouse/management.py@@ -45,7 +45,7 @@ class StockData(NamedTuple):@traced_atomic_transaction()def allocate_stocks(- order_lines_info: Iterable["OrderLineInfo"],+ order_lines_info: list["OrderLineInfo"],country_code: str,channel: "Channel",manager: PluginsManager,@@ -280,9 +280,7 @@ def _create_allocations(return [], allocations-def deallocate_stock(- order_lines_data: Iterable["OrderLineInfo"], manager: PluginsManager-):+def deallocate_stock(order_lines_data: list["OrderLineInfo"], manager: PluginsManager):"""Deallocate stocks for given `order_lines`.Function lock for update stocks and allocations related to given `order_lines`.@@ -408,7 +406,7 @@ def increase_stock(@traced_atomic_transaction()def increase_allocations(- lines_info: Iterable["OrderLineInfo"], channel: "Channel", manager: PluginsManager+ lines_info: list["OrderLineInfo"], channel: "Channel", manager: PluginsManager):"""Increase allocation for order lines with appropriate quantity."""line_pks = [info.line.pk for info in lines_info]@@ -437,7 +435,7 @@ def increase_allocations(Allocation.objects.filter(pk__in=allocation_pks_to_delete).delete()Stock.objects.bulk_update(stocks_to_update, ["quantity_allocated"])- order = lines_info[0].line.order # type: ignore[index]+ order = lines_info[0].line.ordercountry_code = get_active_country(channel, order.shipping_address, order.billing_address)@@ -449,7 +447,7 @@ def increase_allocations()-def decrease_allocations(lines_info: Iterable["OrderLineInfo"], manager):+def decrease_allocations(lines_info: list["OrderLineInfo"], manager):"""Decreate allocations for provided order lines."""tracked_lines = get_order_lines_with_track_inventory(lines_info)if not tracked_lines:@@ -459,7 +457,7 @@ def decrease_allocations(lines_info: Iterable["OrderLineInfo"], manager):@traced_atomic_transaction()def decrease_stock(- order_lines_info: Iterable["OrderLineInfo"],+ order_lines_info: list["OrderLineInfo"],manager,update_stocks=True,allow_stock_to_be_exceeded: bool = False,@@ -531,7 +529,7 @@ def decrease_stock(def _decrease_stocks_quantity(- order_lines_info: Iterable["OrderLineInfo"],+ order_lines_info: list["OrderLineInfo"],variant_and_warehouse_to_stock: dict[int, dict[UUID, Stock]],quantity_allocation_for_stocks: dict[int, int],allow_stock_to_be_exceeded: bool = False,@@ -540,11 +538,11 @@ def _decrease_stocks_quantity(stocks_to_update = []for line_info in order_lines_info:variant = line_info.variant+ if not variant:+ continuewarehouse_pk = line_info.warehouse_pkstock = (- variant_and_warehouse_to_stock.get(variant.pk, {}).get( # type: ignore- warehouse_pk- )+ variant_and_warehouse_to_stock.get(variant.pk, {}).get(warehouse_pk)if warehouse_pkelse None)@@ -585,8 +583,8 @@ def _decrease_stocks_quantity(def get_order_lines_with_track_inventory(- order_lines_info: Iterable["OrderLineInfo"],-) -> Iterable["OrderLineInfo"]:+ order_lines_info: list["OrderLineInfo"],+) -> list["OrderLineInfo"]:"""Return order lines with variants with track inventory set to True."""return [line_info@@ -647,7 +645,7 @@ def deallocate_stock_for_orders(orders_id, manager: PluginsManager):@traced_atomic_transaction()def allocate_preorders(- order_lines_info: Iterable["OrderLineInfo"],+ order_lines_info: list["OrderLineInfo"],channel_slug: str,check_reservations: bool = False,checkout_lines: Optional[Iterable["CheckoutLine"]] = None,@@ -748,8 +746,8 @@ def allocate_preorders(def get_order_lines_with_preorder(- order_lines_info: Iterable["OrderLineInfo"],-) -> Iterable["OrderLineInfo"]:+ order_lines_info: list["OrderLineInfo"],+) -> list["OrderLineInfo"]:"""Return order lines with variants with preorder flag set to True."""return [line_info@@ -891,7 +889,7 @@ def _get_stock_for_preorder_allocation(if shipping_method_id is not None:warehouse = Warehouse.objects.filter(- shipping_zones__id=order.shipping_method.shipping_zone_id # type: ignore+ shipping_zones__id=order.shipping_method.shipping_zone_id # type: ignore[misc,union-attr]).first()else:from ..order.utils import get_order_countrydiff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.pyindex fed0dd9f2d..bcb33dc2b4 100644--- a/saleor/warehouse/models.py+++ b/saleor/warehouse/models.py@@ -287,7 +287,7 @@ class Warehouse(ModelWithMetadata, ModelWithExternalReference):ordering = ("-slug",)indexes = [*ModelWithMetadata.Meta.indexes,- BTreeIndex( # type: ignore+ BTreeIndex(name="click_and_collect_option_idx",fields=["click_and_collect_option"],),diff --git a/saleor/warehouse/reservations.py b/saleor/warehouse/reservations.pyindex 604c18dd6e..101a024c07 100644--- a/saleor/warehouse/reservations.py+++ b/saleor/warehouse/reservations.py@@ -282,7 +282,7 @@ def reserve_preorders(variants_global_allocations = {variant_id: sum(- channel_listing.preorder_quantity_allocated # type: ignore+ channel_listing.preorder_quantity_allocated # type: ignore[attr-defined]for channel_listing in channel_listings)for variant_id, channel_listings in variant_channels.items()@@ -330,7 +330,7 @@ def _create_preorder_reservation(reserved_until: datetime.datetime,):if listing.preorder_quantity_threshold is not None:- available_channel_quantity = listing.available_preorder_quantity # type: ignore+ available_channel_quantity = listing.available_preorder_quantity # type: ignore[attr-defined]available_channel_quantity = max(available_channel_quantity - listings_reservations[listing.id], 0)diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex 45ce855702..90cf639a71 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -119,7 +119,7 @@ def generate_requestor(requestor: Optional["RequestorOrLazyObject"] = None):return {"id": None, "type": None}if isinstance(requestor, User):return {"id": graphene.Node.to_global_id("User", requestor.id), "type": "user"}- return {"id": requestor.name, "type": "app"} # type: ignore+ return {"id": requestor.name, "type": "app"} # type: ignore[union-attr]def generate_meta(*, requestor_data: dict[str, Any], camel_case=False, **kwargs):@@ -1282,7 +1282,7 @@ def generate_excluded_shipping_methods_for_checkout_payload(@traced_payload_generatordef generate_checkout_payload_for_tax_calculation(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],):checkout = checkout_info.checkouttax_configuration = checkout_info.tax_configurationdiff --git a/saleor/webhook/serializers.py b/saleor/webhook/serializers.pyindex faad3de3ae..9cd3961b13 100644--- a/saleor/webhook/serializers.py+++ b/saleor/webhook/serializers.py@@ -1,6 +1,5 @@import datetimefrom collections import defaultdict-from collections.abc import Iterablefrom decimal import Decimalfrom typing import TYPE_CHECKING, Any, Optional, Union@@ -80,7 +79,7 @@ def _get_checkout_line_payload_data(line_info: "CheckoutLineInfo") -> dict[str,def serialize_checkout_lines_for_tax_calculation(checkout_info: "CheckoutInfo",- lines: Iterable["CheckoutLineInfo"],+ lines: list["CheckoutLineInfo"],) -> list[dict]:charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)return [