Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Apply textwrap.decent to GraphQL descriptions
fowczarek7f660d659f9e
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.pyindex e2c2091d2f..559ef7391c 100644--- a/saleor/graphql/core/mutations.py+++ b/saleor/graphql/core/mutations.py@@ -7,6 +7,7 @@ from graphene_django.registry import get_global_registryfrom graphql.error import GraphQLErrorfrom graphql_jwt import ObtainJSONWebToken, Verifyfrom graphql_jwt.exceptions import JSONWebTokenError, PermissionDenied+from textwrap import dedentfrom ...account import modelsfrom ..account.types import User@@ -49,6 +50,7 @@ class BaseMutation(graphene.Mutation):def __init_subclass_with_meta__(cls, description=None, **options):if not description:raise ImproperlyConfigured('No description provided in Meta')+ description = dedent(description)super().__init_subclass_with_meta__(description=description, **options)@classmethoddiff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.pyindex 1ae3fea4f1..0dad146523 100644--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@ -4,6 +4,7 @@ import graphenefrom graphene_django import DjangoObjectTypefrom saleor.core.permissions import MODELS_PERMISSIONSfrom saleor.graphql.core.utils import str_to_enum+from textwrap import dedentfrom ....core import weightfrom ..connection import CountableConnection@@ -52,9 +53,9 @@ class CountableDjangoObjectType(DjangoObjectType):class Error(graphene.ObjectType):field = graphene.String(- description="""Name of a field that caused the error. A value of+ description=dedent("""Name of a field that caused the error. A value of`null` indicates that the error isn't associated with a particular- field.""", required=False)+ field."""), required=False)message = graphene.String(description='The error message.')class Meta:diff --git a/saleor/graphql/core/types/money.py b/saleor/graphql/core/types/money.pyindex 7e230db805..c92c101c03 100644--- a/saleor/graphql/core/types/money.py+++ b/saleor/graphql/core/types/money.py@@ -1,5 +1,6 @@import graphenefrom django_prices.templatetags import prices_i18n+from textwrap import dedentfrom ....core import TaxRateType as TaxRatesfrom ..utils import str_to_enum@@ -38,9 +39,9 @@ class TaxedMoney(graphene.ObjectType):tax = graphene.Field(Money, description='Amount of taxes.', required=True)class Meta:- description = """Represents a monetary value with taxes. In+ description = dedent("""Represents a monetary value with taxes. Incase when taxes were not applied, net and gross values will be equal.- """+ """)class TaxedMoneyRange(graphene.ObjectType):@@ -59,8 +60,8 @@ class VAT(graphene.ObjectType):description='Standard VAT rate in percent.')reduced_rates = graphene.List(lambda: ReducedRate,- description='''- Country\'s VAT rate exceptions for specific types of goods.''')+ description=dedent('''+ Country\'s VAT rate exceptions for specific types of goods.'''))class Meta:description = 'Represents a VAT rate for a country.'@@ -81,8 +82,8 @@ class ReducedRate(graphene.ObjectType):rate_type = graphene.String(description='A type of goods.', required=True)class Meta:- description = '''- Represents a reduced VAT rate for a particular type of goods.'''+ description = dedent('''+ Represents a reduced VAT rate for a particular type of goods.''')TaxRateType = graphene.Enum(diff --git a/saleor/graphql/discount/types.py b/saleor/graphql/discount/types.pyindex 4a82a4af57..c18d27e779 100644--- a/saleor/graphql/discount/types.py+++ b/saleor/graphql/discount/types.py@@ -1,6 +1,7 @@import grapheneimport graphene_django_optimizer as gql_optimizerfrom graphene import relay+from textwrap import dedentfrom ..core.fields import PrefetchingConnectionFieldfrom ...discount import DiscountValueType, VoucherType, models@@ -26,10 +27,10 @@ class Voucher(CountableDjangoObjectType):model_field='products')class Meta:- description = """+ description = dedent("""Vouchers allow giving discounts to particular customers on categories,collections or specific products. They can be used during checkout by- providing valid voucher codes."""+ providing valid voucher codes.""")interfaces = [relay.Node]model = models.Voucher@@ -61,9 +62,9 @@ class Sale(CountableDjangoObjectType):model_field='products')class Meta:- description = """+ description = dedent("""Sales allow creating discounts for categories, collections or- products and are visible to all the customers."""+ products and are visible to all the customers.""")interfaces = [relay.Node]model = models.Salediff --git a/saleor/graphql/file_upload/types.py b/saleor/graphql/file_upload/types.pyindex 06d96f1e6a..d809afb682 100644--- a/saleor/graphql/file_upload/types.py+++ b/saleor/graphql/file_upload/types.py@@ -1,13 +1,14 @@import graphene+from textwrap import dedentclass Upload(graphene.types.Scalar):class Meta:- description = '''Variables of this type must be set to null in+ description = dedent('''Variables of this type must be set to null inmutations. They will be replaced with a filename from a followingmultipart part containing a binary file. See:- https://github.com/jaydenseric/graphql-multipart-request-spec'''+ https://github.com/jaydenseric/graphql-multipart-request-spec''')@staticmethoddef serialize(value):diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.pyindex 8d6a9d0467..0ec83165d9 100644--- a/saleor/graphql/menu/mutations.py+++ b/saleor/graphql/menu/mutations.py@@ -1,5 +1,6 @@import graphenefrom graphql_jwt.decorators import permission_required+from textwrap import dedentfrom ...menu import modelsfrom ..core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation@@ -24,9 +25,9 @@ class MenuItemCreateInput(MenuItemInput):description='Menu to which item belongs to.', name='menu',required=True)parent = graphene.ID(- description='''+ description=dedent('''ID of the parent menu. If empty, menu will be top level- menu.''',+ menu.'''),name='parent')@@ -128,9 +129,9 @@ class MenuItemCreate(ModelMutation):class Arguments:input = MenuItemCreateInput(required=True,- description="""Fields required to update a menu item.+ description=dedent("""Fields required to update a menu item.Only one of 'url', 'category', 'page', 'collection' is allowed- per item""")+ per item"""))class Meta:description = 'Creates a new Menu'@@ -160,9 +161,9 @@ class MenuItemUpdate(MenuItemCreate):required=True, description='ID of a menu item to update.')input = MenuItemInput(required=True,- description="""Fields required to update a menu item.+ description=dedent("""Fields required to update a menu item.Only one of 'url', 'category', 'page', 'collection' is allowed- per item""")+ per item"""))class Meta:description = 'Updates a menu item.'diff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.pyindex 00fec1e555..ee01b44371 100644--- a/saleor/graphql/menu/types.py+++ b/saleor/graphql/menu/types.py@@ -2,6 +2,7 @@ import grapheneimport graphene_django_optimizer as gql_optimizerfrom django.db.models import Prefetchfrom graphene import relay+from textwrap import dedentfrom ...menu import modelsfrom ..core.types.common import CountableDjangoObjectType@@ -23,8 +24,13 @@ class Menu(CountableDjangoObjectType):prefetch_related=prefetch_menus)class Meta:+<<<<<<< HEADdescription = """Represents a single menu - an object that is usedto help navigate through the store."""+=======+ description = dedent("""Represents a single item of the related menu.+ Can store categories, collection or pages.""")+>>>>>>> Apply textwrap.decent to GraphQL descriptionsinterfaces = [relay.Node]exclude_fields = ['json_content']model = models.Menu@@ -41,8 +47,13 @@ class MenuItem(CountableDjangoObjectType):url = graphene.String(description='URL to the menu item.')class Meta:+<<<<<<< HEADdescription = """Represents a single item of the related menu.Can store categories, collection or pages."""+=======+ description = dedent("""Represents a single menu - an object that is+ used to help navigate through the store.""")+>>>>>>> Apply textwrap.decent to GraphQL descriptionsinterfaces = [relay.Node]exclude_fields = ['sort_order', 'lft', 'rght', 'tree_id']model = models.MenuItemdiff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.pyindex c582bb047b..602960eb21 100644--- a/saleor/graphql/order/mutations/draft_orders.py+++ b/saleor/graphql/order/mutations/draft_orders.py@@ -1,6 +1,7 @@import graphenefrom graphene.types import InputObjectTypefrom graphql_jwt.decorators import permission_required+from textwrap import dedentfrom ....account.models import Address, Userfrom ....core.exceptions import InsufficientStock@@ -44,8 +45,8 @@ class DraftOrderInput(InputObjectType):class DraftOrderCreateInput(DraftOrderInput):lines = graphene.List(OrderLineCreateInput,- description="""Variant line input consisting of variant ID- and quantity of products.""")+ description=dedent("""Variant line input consisting of variant ID+ and quantity of products."""))class DraftOrderCreate(ModelMutation):@@ -247,9 +248,9 @@ class DraftOrderLineCreate(BaseMutation):description='ID of the draft order to add the lines to.')input = OrderLineCreateInput(required=True,- description="""+ description=dedent("""Variant line input consisting of variant ID and quantity of- products.""")+ products."""))class Meta:description = 'Create an order line for a draft order.'diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.pyindex ec748342f6..91d153697e 100644--- a/saleor/graphql/order/mutations/fulfillments.py+++ b/saleor/graphql/order/mutations/fulfillments.py@@ -1,6 +1,7 @@import graphenefrom django.utils.translation import npgettext_lazy, pgettext_lazyfrom graphql_jwt.decorators import permission_required+from textwrap import dedentfrom ....dashboard.order.utils import fulfill_order_linefrom ....order import OrderEvents, OrderEventsEmails, models@@ -192,8 +193,8 @@ class FulfillmentCancel(BaseMutation):description='Fields required to cancel an fulfillment.')class Meta:- description = """Cancels existing fulfillment- and optionally restocks items."""+ description = dedent("""Cancels existing fulfillment+ and optionally restocks items.""")@classmethod@permission_required('order.manage_orders')diff --git a/saleor/graphql/page/mutations.py b/saleor/graphql/page/mutations.pyindex 5e90151d0f..58c70a917d 100644--- a/saleor/graphql/page/mutations.py+++ b/saleor/graphql/page/mutations.py@@ -1,5 +1,6 @@import graphenefrom django.utils.text import slugify+from textwrap import dedentfrom ...page import modelsfrom ..core.mutations import ModelDeleteMutation, ModelMutation@@ -11,8 +12,8 @@ class PageInput(graphene.InputObjectType):slug = graphene.String(description='Page internal name.')title = graphene.String(description='Page title.')content = graphene.String(- description="""Page content.- May consists of ordinary text, HTML and images.""")+ description=dedent("""Page content.+ May consists of ordinary text, HTML and images."""))is_visible = graphene.Boolean(description='Determines if page is visible in the storefront')available_on = graphene.String(diff --git a/saleor/graphql/page/types.py b/saleor/graphql/page/types.pyindex 89b26d5212..ed46c73214 100644--- a/saleor/graphql/page/types.py+++ b/saleor/graphql/page/types.py@@ -1,4 +1,5 @@from graphene import relay+from textwrap import dedentfrom ...page import modelsfrom ..core.types.common import CountableDjangoObjectType@@ -6,8 +7,8 @@ from ..core.types.common import CountableDjangoObjectTypeclass Page(CountableDjangoObjectType):class Meta:- description = """A static page that can be manually added by a shop- operator through the dashboard."""+ description = dedent("""A static page that can be manually added by a shop+ operator through the dashboard.""")exclude_fields = ['voucher_set', 'sale_set', 'menuitem_set']interfaces = [relay.Node]model = models.Pagediff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 83202cce76..e3ae25033b 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -2,6 +2,7 @@ import graphenefrom django.template.defaultfilters import slugifyfrom graphene.types import InputObjectTypefrom graphql_jwt.decorators import permission_required+from textwrap import dedentfrom ....product import modelsfrom ....product.utils.attributes import get_name_from_attributes@@ -18,7 +19,6 @@ from ..utils import attributes_to_hstore, update_variants_namesclass CategoryInput(graphene.InputObjectType):description = graphene.String(description='Category description')name = graphene.String(description='Category name')-slug = graphene.String(description='Category slug')seo = SeoInput(description='Search engine optimization fields.')background_image = Upload(description='Background image file.')@@ -326,9 +326,9 @@ class ProductVariantInput(graphene.InputObjectType):quantity = graphene.Int(description='The total quantity of this variant available for sale.')track_inventory = graphene.Boolean(- description="""Determines if the inventory of this variant should+ description=dedent("""Determines if the inventory of this variant shouldbe tracked. If false, the quantity won't change when customers- buy this item.""")+ buy this item."""))weight = WeightScalar(description='Weight of the Product Variant.', required=False)@@ -433,22 +433,22 @@ class ProductVariantDelete(ModelDeleteMutation):class ProductTypeInput(graphene.InputObjectType):name = graphene.String(description='Name of the product type.')has_variants = graphene.Boolean(- description="""Determines if product of this type has multiple+ description=dedent("""Determines if product of this type has multiplevariants. This option mainly simplifies product managementin the dashboard. There is always at least one variant created under- the hood.""")+ the hood."""))product_attributes = graphene.List(graphene.ID,description='List of attributes shared among all product variants.',name='productAttributes')variant_attributes = graphene.List(graphene.ID,- description="""List of attributes used to distinguish between- different variants of a product.""",+ description=dedent("""List of attributes used to distinguish between+ different variants of a product."""),name='variantAttributes')is_shipping_required = graphene.Boolean(- description="""Determines if shipping is required for products- of this variant.""")+ description=dedent("""Determines if shipping is required for products+ of this variant."""))weight = WeightScalar(description='Weight of the ProductType items.')tax_rate = TaxRateType(description='A type of goods.')@@ -530,10 +530,10 @@ class ProductImageCreate(BaseMutation):description='Fields required to create a product image.')class Meta:- description = '''Create a product image. This mutation must be sent- as a `multipart` request. More detailed specs of the upload format can- be found here:- https://github.com/jaydenseric/graphql-multipart-request-spec'''+ description = dedent('''Create a product image. This mutation must be+ sent as a `multipart` request. More detailed specs of the upload format+ can be found here:+ https://github.com/jaydenseric/graphql-multipart-request-spec''')@classmethod@permission_required('product.manage_products')diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex 7c71be7f98..c89394b3d7 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -5,6 +5,7 @@ import graphene_django_optimizer as gql_optimizerfrom django.db.models import Prefetchfrom graphene import relayfrom graphql.error import GraphQLError+from textwrap import dedentfrom ...product import modelsfrom ...product.templatetags.product_images import get_thumbnail@@ -98,8 +99,8 @@ class Attribute(CountableDjangoObjectType):model_field='values')class Meta:- description = """Custom attribute of a product. Attributes can be- assigned to products and variants at the product type level."""+ description = dedent("""Custom attribute of a product. Attributes can be+ assigned to products and variants at the product type level.""")exclude_fields = []interfaces = [relay.Node]model = models.Attribute@@ -129,8 +130,9 @@ class ProductVariant(CountableDjangoObjectType):required=True, description='Quantity of a product available for sale.')price_override = graphene.Field(Money,- description="""Override the base price of a product if necessary.- A value of `null` indicates that the default product price is used.""")+ description=dedent("""Override the base price of a product if necessary.+ A value of `null` indicates that the default product+ price is used."""))price = graphene.Field(Money, description="Price of the product variant.")attributes = graphene.List(SelectedAttribute,@@ -146,8 +148,8 @@ class ProductVariant(CountableDjangoObjectType):query as it uses optimizations suitable for such calculations.''')class Meta:- description = """Represents a version of a product such as different- size or color."""+ description = dedent("""Represents a version of a product such as+ different size or color.""")exclude_fields = ['variant_images']interfaces = [relay.Node]model = models.ProductVariant@@ -221,12 +223,12 @@ class Product(CountableDjangoObjectType):size=graphene.Argument(graphene.Int, description='Size of thumbnail'))availability = graphene.Field(ProductAvailability,- description="""Informs about product's availability in the storefront,- current price and discounts.""")+ description=dedent("""Informs about product's availability in the+ storefront, current price and discounts."""))price = graphene.Field(Money,- description="""The product's base price (without any discounts- applied).""")+ description=dedent("""The product's base price (without any discounts+ applied)."""))attributes = graphene.List(SelectedAttribute,description='List of attributes assigned to this product.')@@ -243,8 +245,8 @@ class Product(CountableDjangoObjectType):PrefetchingConnectionField(lambda: ProductImage), model_field='images')class Meta:- description = """Represents an individual item for sale in the- storefront."""+ description = dedent("""Represents an individual item for sale in the+ storefront.""")interfaces = [relay.Node]model = models.Product@@ -330,8 +332,8 @@ class ProductType(CountableDjangoObjectType):Attribute, description='Product attributes of that product type.')class Meta:- description = """Represents a type of product. It defines what- attributes are available to products of this type."""+ description = dedent("""Represents a type of product. It defines what+ attributes are available to products of this type.""")interfaces = [relay.Node]model = models.ProductType@@ -387,9 +389,9 @@ class Category(CountableDjangoObjectType):background_image = graphene.Field(Image)class Meta:- description = """Represents a single category of products. Categories- allow to organize products in a tree-hierarchies which can be used for- navigation in the storefront."""+ description = dedent("""Represents a single category of products.+ Categories allow to organize products in a tree-hierarchies which can+ be used for navigation in the storefront.""")exclude_fields = ['lft', 'rght', 'tree_id', 'voucher_set', 'sale_set','menuitem_set']diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.pyindex b4c00e9e5f..275349e692 100644--- a/saleor/graphql/shipping/mutations.py+++ b/saleor/graphql/shipping/mutations.py@@ -1,4 +1,5 @@import graphene+from textwrap import dedentfrom ...dashboard.shipping.forms import default_shipping_zone_existsfrom ...shipping import models@@ -37,9 +38,9 @@ class ShippingZoneInput(graphene.InputObjectType):graphene.String,description='List of countries in this shipping zone.')default = graphene.Boolean(- description="""+ description=dedent("""Is default shipping zone, that will be used- for countries not covered by other zones.""")+ for countries not covered by other zones."""))class ShippingZoneMixin:diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.pyindex 6d6c161594..a08acfce1e 100644--- a/saleor/graphql/shipping/types.py+++ b/saleor/graphql/shipping/types.py@@ -5,6 +5,7 @@ import graphene_django_optimizer as gql_optimizerfrom graphene import relayfrom graphene.types import Scalarfrom measurement.measures import Weight+from textwrap import dedentfrom ...core.weight import convert_weight, get_default_weight_unitfrom ...shipping import ShippingMethodType, models@@ -20,10 +21,10 @@ class ShippingMethod(CountableDjangoObjectType):type = ShippingMethodTypeEnum(description='Type of the shipping method.')class Meta:- description = """+ description = dedent("""Shipping method are the methods you'll use to getcustomer's orders to them.- They are directly exposed to the customers."""+ They are directly exposed to the customers.""")model = models.ShippingMethodinterfaces = [relay.Node]exclude_fields = ['shipping_zone', 'orders']@@ -44,10 +45,10 @@ class ShippingZone(CountableDjangoObjectType):model_field='shipping_methods')class Meta:- description = """+ description = dedent("""Represents a shipping zone in the shop. Zones are the conceptused only for grouping shipping methods in the dashboard,- and are never exposed to the customers directly."""+ and are never exposed to the customers directly.""")model = models.ShippingZoneinterfaces = [relay.Node]diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.pyindex 12d5f63519..887824585d 100644--- a/saleor/graphql/shop/types.py+++ b/saleor/graphql/shop/types.py@@ -4,6 +4,7 @@ from django.conf import settingsfrom django_countries import countriesfrom graphql_jwt.decorators import permission_requiredfrom phonenumbers import COUNTRY_CODE_TO_REGION_CODE+from textwrap import dedentfrom ...core.permissions import get_permissionsfrom ...core.utils import get_client_ip, get_country_by_ip@@ -65,9 +66,9 @@ class Shop(graphene.ObjectType):description='Customer\'s geolocalization data.')authorization_keys = graphene.List(AuthorizationKey,- description='''List of configured authorization keys. Authorization+ description=dedent('''List of configured authorization keys. Authorizationkeys are used to enable thrid party OAuth authorization (currently- Facebook or Google).''',+ Facebook or Google).'''),required=True)countries = graphene.List(CountryDisplay, description='List of countries available in the shop.',@@ -106,9 +107,9 @@ class Shop(graphene.ObjectType):default_weight_unit = WeightUnitsEnum(description='Default weight unit')class Meta:- description = '''+ description = dedent('''Represents a shop resource containing general shop\'s data- and configuration.'''+ and configuration.''')@permission_required('site.manage_settings')def resolve_authorization_keys(self, info):