Skip to content

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

Fix pydocstyle errors

Anna Siwikc9b5ccebaf15
diff --git a/saleor/discount/utils.py b/saleor/discount/utils.py
index d6bf42d430..ed7a169c11 100644
--- a/saleor/discount/utils.py
+++ b/saleor/discount/utils.py
@@ -12,19 +12,19 @@ from . import VoucherApplyToProduct, VoucherType
def increase_voucher_usage(voucher):
- """Increases voucher uses by 1."""
+ """Increase voucher uses by 1."""
voucher.used = F('used') + 1
voucher.save(update_fields=['used'])
def decrease_voucher_usage(voucher):
- """Decreases voucher uses by 1."""
+ """Decrease voucher uses by 1."""
voucher.used = F('used') - 1
voucher.save(update_fields=['used'])
def is_category_on_sale(category, sale):
- """Checks if category is descendant of one of categories on sale."""
+ """Check if category is descendant of one of categories on sale."""
discounted_categories = set(sale.categories.all())
return any([
category.is_descendant_of(c, include_self=True)
@@ -32,8 +32,7 @@ def is_category_on_sale(category, sale):
def get_product_discount_on_sale(sale, product):
- """Returns discount value if product is on sale or raises NotApplicable
- elsewhere."""
+ """Return discount value if product is on sale or raise NotApplicable."""
discounted_products = {p.pk for p in sale.products.all()}
is_product_on_sale = (
product.pk in discounted_products or
@@ -47,7 +46,7 @@ def get_product_discount_on_sale(sale, product):
def get_product_discounts(product, discounts):
- """Returns discount values for all discounts applicable to a product."""
+ """Return discount values for all discounts applicable to a product."""
for discount in discounts:
try:
yield get_product_discount_on_sale(discount, product)
@@ -56,7 +55,7 @@ def get_product_discounts(product, discounts):
def calculate_discounted_price(product, price, discounts):
- """Returns minimum product's price of all prices with discounts applied."""
+ """Return minimum product's price of all prices with discounts applied."""
if discounts:
discounts = list(
get_product_discounts(product, discounts))
@@ -66,14 +65,14 @@ def calculate_discounted_price(product, price, discounts):
def _get_value_voucher_discount_for_checkout(voucher, checkout):
- """Calculates discount value for a voucher of value type."""
+ """Calculate discount value for a voucher of value type."""
cart_total = checkout.get_subtotal()
voucher.validate_limit(cart_total)
return voucher.get_fixed_discount_for(cart_total)
def _get_shipping_voucher_discount_for_checkout(voucher, checkout):
- """Calculates discount value for a voucher of shipping type."""
+ """Calculate discount value for a voucher of shipping type."""
if not checkout.is_shipping_required:
msg = pgettext(
'Voucher not applicable',
@@ -99,7 +98,7 @@ def _get_shipping_voucher_discount_for_checkout(voucher, checkout):
def _get_product_or_category_voucher_discount_for_checkout(voucher, checkout):
- """Calculates discount value for a voucher of product or category type."""
+ """Calculate discount value for a voucher of product or category type."""
if voucher.type == VoucherType.PRODUCT:
prices = [
item[1] for item in get_product_variants_and_prices(
@@ -126,9 +125,10 @@ def _get_product_or_category_voucher_discount_for_checkout(voucher, checkout):
def get_voucher_discount_for_checkout(voucher, checkout):
- """Calculates discount value depending on voucher and discount types.
+ """Calculate discount value depending on voucher and discount types.
- Raises NotApplicable if voucher of given type cannot be applied."""
+ Raise NotApplicable if voucher of given type cannot be applied.
+ """
if voucher.type == VoucherType.VALUE:
return _get_value_voucher_discount_for_checkout(voucher, checkout)
if voucher.type == VoucherType.SHIPPING: