Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix incorrect type definition
Maciej Korycinski2a7f13c25908
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 49774989f2..6162088be3 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Iterable, List, Optional, Tuplefrom django.core.exceptions import ValidationErrorfrom django.db.models import Max, Min, Sumfrom django.utils import timezone+from django_countries.fields import Countryfrom prices import Money, MoneyRange, TaxedMoneyRangefrom ..account.models import User@@ -558,7 +559,7 @@ def get_valid_shipping_methods_for_checkout(checkout,channel_id=checkout.channel_id,price=subtotal.gross,- country_code=country_code,+ country_code=country_code, # type: ignorelines=lines,)@@ -612,7 +613,9 @@ def get_shipping_price_estimate(start=Money(min_price_amount, checkout.currency),stop=Money(max_price_amount, checkout.currency),)- return manager.apply_taxes_to_shipping_price_range(prices, country_code)+ return manager.apply_taxes_to_shipping_price_range(+ prices, country_code # type: ignore+ )def clear_shipping_method(checkout: Checkout):diff --git a/saleor/graphql/product/tests/test_variant_pricing.py b/saleor/graphql/product/tests/test_variant_pricing.pyindex f800f29729..9b2b46da3f 100644--- a/saleor/graphql/product/tests/test_variant_pricing.py+++ b/saleor/graphql/product/tests/test_variant_pricing.py@@ -1,5 +1,6 @@from unittest.mock import Mock+from django_countries.fields import Countryfrom prices import Money, TaxedMoneyfrom ....plugins.manager import PluginsManager@@ -142,7 +143,7 @@ def test_variant_pricing(discounts=[],channel=channel_USD,local_currency="PLN",- country="US",+ country=Country("US"),)assert pricing.price_local_currency.currency == "PLN" # type: ignorediff --git a/saleor/product/tests/test_product_availability.py b/saleor/product/tests/test_product_availability.pyindex 760513586b..7767254c88 100644--- a/saleor/product/tests/test_product_availability.py+++ b/saleor/product/tests/test_product_availability.py@@ -2,6 +2,7 @@ import datetimefrom decimal import Decimalfrom unittest.mock import Mock+from django_countries.fields import Countryfrom freezegun import freeze_timefrom prices import Money, TaxedMoney, TaxedMoneyRange@@ -29,7 +30,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):channel=channel_USD,collections=[],discounts=[],- country="PL",+ country=Country("PL"),)taxed_price_range = TaxedMoneyRange(start=taxed_price, stop=taxed_price)assert availability.price_range == taxed_price_range@@ -50,7 +51,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):discounts=[],channel=channel_USD,local_currency="PLN",- country="PL",+ country=Country("PL"),)assert availability.price_range_local_currency.start.currency == "PLN"@@ -62,7 +63,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):collections=[],discounts=[],channel=channel_USD,- country="PL",+ country=Country("PL"),)assert availability.price_range.start.tax.amountassert availability.price_range.stop.tax.amount@@ -91,7 +92,7 @@ def test_availability_with_all_variant_channel_listings(stock, channel_USD):channel=channel_USD,collections=[],discounts=[],- country="PL",+ country=Country("PL"),)# then@@ -120,7 +121,7 @@ def test_availability_with_missing_variant_channel_listings(stock, channel_USD):channel=channel_USD,collections=[],discounts=[],- country="PL",+ country=Country("PL"),)# then@@ -147,7 +148,7 @@ def test_availability_without_variant_channel_listings(stock, channel_USD):channel=channel_USD,collections=[],discounts=[],- country="PL",+ country=Country("PL"),)# thendiff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.pyindex a26c4cd6f3..b131d3064a 100644--- a/saleor/product/utils/availability.py+++ b/saleor/product/utils/availability.py@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Unionimport opentracingfrom django.conf import settings+from django_countries.fields import Countryfrom prices import MoneyRange, TaxedMoney, TaxedMoneyRangefrom ...channel.models import Channel@@ -146,10 +147,11 @@ def get_product_availability(collections: Iterable[Collection],discounts: Iterable[DiscountInfo],channel: Channel,- country: Optional[str] = None,+ country: Optional[Country] = None,local_currency: Optional[str] = None,plugins: Optional["PluginsManager"] = None,) -> ProductAvailability:+ country = country or Country(settings.DEFAULT_COUNTRY)with opentracing.global_tracer().start_active_span("get_product_availability"):if not plugins:plugins = get_plugins_manager()@@ -223,10 +225,11 @@ def get_variant_availability(collections: Iterable[Collection],discounts: Iterable[DiscountInfo],channel: Channel,- country: Optional[str] = None,+ country: Optional[Country] = None,local_currency: Optional[str] = None,plugins: Optional["PluginsManager"] = None,) -> VariantAvailability:+ country = country or Country(settings.DEFAULT_COUNTRY)with opentracing.global_tracer().start_active_span("get_variant_availability"):if not plugins:plugins = get_plugins_manager()