Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix PEP8 issues
NyanKiyoshi357d7fd37794
diff --git a/saleor/core/utils/text.py b/saleor/core/utils/text.pyindex 6fa80a3906..211c16b9ba 100644--- a/saleor/core/utils/text.py+++ b/saleor/core/utils/text.py@@ -4,7 +4,9 @@ from html5lib.serializer import HTMLSerializerdef trim_text(text: str, max_length: int, suffix: str=''):"""Trims a given text in accordance to parameters.- If text length is greater than allowed, it trims it and add a given suffix to the text.+ If text length is greater than allowed,+ it trims it and add a given suffix to the text.+Note that the text + suffix is equal to the max length.Example:@@ -54,14 +56,16 @@ def get_cleaner(**serializer_kwargs: bool):cleaner = bleach.Cleaner([], strip=True)for k, v in serializer_kwargs.items():if k not in HTMLSerializer.options:- raise ValueError('Parameter %s is not a valid option for HTMLSerializer' % k)+ raise ValueError(+ 'Parameter %s is not a valid option for HTMLSerializer' % k)setattr(cleaner.serializer, k, v)return cleanerdef strip_html(text: str, **serializer_kwargs: bool):"""Removes (strips) HTML tags from text.- Can also take additional parameters to be passed to the serializer (see `get_cleaner`).+ Can also take additional parameters+ to be passed to the serializer (see `get_cleaner`).:param text::type text: strdiff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 8daa5ad69e..6a0326a0ae 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -8,8 +8,8 @@ from django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazy-from saleor.core.utils.text import strip_html, trim_textfrom . import ProductBulkAction+from ...core.utils.text import strip_html, trim_textfrom ...product.models import (AttributeChoiceValue, Collection, Product, ProductAttribute, ProductImage,ProductType, ProductVariant, Stock, StockLocation, VariantImage)@@ -172,15 +172,19 @@ class ProductForm(forms.ModelForm):@classmethoddef generate_seo_description(cls, html_text):- """Strips HTML tags and whitespaces from text, then trim the description."""+ """Strips HTML tags and whitespaces from text,+ then trim the description."""text = strip_html(html_text, strip_whitespace=True)- text = trim_text(text, settings.GENERATED_SEO_MAX_LENGTH, settings.GENERATED_SEO_SUFFIX)+ text = trim_text(text,+ settings.GENERATED_SEO_MAX_LENGTH,+ settings.GENERATED_SEO_SUFFIX)return textdef clean_seo_description(self):seo_description = self.cleaned_data['seo_description']- # if there is no SEO friendly description set, generate it from the HTML description+ # if there is no SEO friendly description set,+ # generate it from the HTML descriptionif not seo_description:# get the non-safe description (has non escaped HTML tags in it)product_description = self.data['description']