Skip to content

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

Update the documentation to reflect the use of the black code style

NyanKiyoshi2a20e5b704e4
diff --git a/docs/architecture/events.rst b/docs/architecture/events.rst
index 7ec0934647..797f992abb 100644
--- a/docs/architecture/events.rst
+++ b/docs/architecture/events.rst
@@ -90,8 +90,7 @@ To send an event, simply do the following:
from saleor.order import events
# returns an OrderEvent
- events.note_added_event(
- order=order, user=user, message='hello world!')
+ events.note_added_event(order=order, user=user, message="hello world!")
If now you want to send a 'sent email' event you would do the following:
@@ -100,8 +99,10 @@ If now you want to send a 'sent email' event you would do the following:
from saleor.order import events
events.email_sent_event(
- order=order, user=user,
- email_type=events.OrderEventsEmails.TRACKING_UPDATED)
+ order=order,
+ user=user,
+ email_type=events.OrderEventsEmails.TRACKING_UPDATED,
+ )
Notice how we are providing the email type.
diff --git a/docs/architecture/money.rst b/docs/architecture/money.rst
index 921d6b46bd..7abd379383 100644
--- a/docs/architecture/money.rst
+++ b/docs/architecture/money.rst
@@ -22,7 +22,7 @@ Money and TaxedMoney
In Saleor's codebase, money amounts exist either as `Money` or `TaxedMoney` instances.
-`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, 'USD')`.
+`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, "USD")`.
This type doesn't hold any additional information useful for commerce but, unlike `Decimal`, it implements safeguards and checks for calculations and comparisons of monetary values.
Money amounts are stored on model using `MoneyField` that provides its own safechecks on currency and precision of stored amount.
diff --git a/docs/architecture/translations.rst b/docs/architecture/translations.rst
index 91f58b35a1..322a34b68d 100644
--- a/docs/architecture/translations.rst
+++ b/docs/architecture/translations.rst
@@ -63,12 +63,15 @@ We will use ``ProductTranslation`` to store our translated properties, it requi
class ProductTranslation(models.Model):
language_code = models.CharField(max_length=10)
product = models.ForeignKey(
- Product, related_name='translations', on_delete=models.CASCADE)
+ Product,
+ related_name="translations",
+ on_delete=models.CASCADE,
+ )
name = models.CharField(max_length=128)
description = models.CharField(max_length=256)
class Meta:
- unique_together = ('product', 'language_code')
+ unique_together = ("product", "language_code")
.. note:: Don't forget to set ``unique_together`` on the ``product`` and ``language_code``, there should be only one translation per product per language.
diff --git a/docs/guides/payments.rst b/docs/guides/payments.rst
index d14eb06d4c..4dc85d6ec4 100644
--- a/docs/guides/payments.rst
+++ b/docs/guides/payments.rst
@@ -39,8 +39,8 @@ Example
.. note::
- All the below methods receive ``payment_information`` as a dataclass: ``PaymentData``.
- Methods should return a response as a dataclass: ``GatewayResponse``.
+ All the below methods receive ``payment_information`` as a dataclass: ``PaymentData``.
+ Methods should return a response as a dataclass: ``GatewayResponse``.
The description of the given structures can be found below.
@@ -57,7 +57,8 @@ Example
def authorize(
payment_information: PaymentData,
- connection_params: Dict) -> GatewayResponse:
+ connection_params: Dict,
+ ) -> GatewayResponse:
# Handle connecting to the gateway and sending the auth request here
response = gateway.authorize(token=payment_information.token)
@@ -86,7 +87,8 @@ Example
def refund(
payment_information: PaymentData,
- **connection_params: Dict) -> GatewayResponse:
+ **connection_params: Dict,
+ ) -> GatewayResponse:
# Handle connecting to the gateway and sending the refund request here
response = gateway.refund(token=payment_information.token)
@@ -115,7 +117,8 @@ Example
def capture(
payment_information: PaymentData,
- connection_params: Dict) -> GatewayResponse:
+ connection_params: Dict,
+ ) -> GatewayResponse:
# Handle connecting to the gateway and sending the capture request here
response = gateway.capture(token=payment_information.token)
@@ -144,7 +147,8 @@ Example
def void(
payment_information: PaymentData,
- connection_params: Dict) -> GatewayResponse:
+ connection_params: Dict,
+ ) -> GatewayResponse:
# Handle connecting to the gateway and sending the void request here
response = gateway.void(token=payment_information.token)
@@ -173,7 +177,8 @@ Example
def charge(
payment_information: PaymentData,
- connection_params: Dict) -> GatewayResponse:
+ connection_params: Dict,
+ ) -> GatewayResponse:
# Handle connecting to the gateway and sending the charge request here
response = gateway.charge(
@@ -206,7 +211,8 @@ Example
def process_payment(
payment_information: PaymentData,
- connection_params: Dict) -> GatewayResponse:
+ connection_params: Dict,
+ ) -> GatewayResponse:
# Authorize, update the token, then capture
authorize_response = authorize(
@@ -348,7 +354,7 @@ Example
payment_method_nonce = forms.CharField()
def get_payment_token(self):
- return self.cleaned_data['payment_method_nonce']
+ return self.cleaned_data["payment_method_nonce"]
Implement create_form(data, payment_information, connection_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -365,7 +371,10 @@ Example
def create_form(data, payment_information, connection_params):
return BraintreePaymentForm(
- data, payment_information, connection_params)
+ data,
+ payment_information,
+ connection_params,
+ )
Implement TEMPLATE_PATH
@@ -378,7 +387,7 @@ Example
.. code-block:: python
- TEMPLATE_PATH = 'order/payment/braintree.html'
+ TEMPLATE_PATH = "order/payment/braintree.html"
Add template
^^^^^^^^^^^^
@@ -393,13 +402,13 @@ Adding new payment gateway to the settings
.. code-block:: python
PAYMENT_GATEWAYS = {
- 'braintree': {
- 'module': 'saleor.payment.gateways.braintree',
- 'connection_params': {
- 'sandbox_mode': get_bool_from_env('BRAINTREE_SANDBOX_MODE', True),
- 'merchant_id': os.environ.get('BRAINTREE_MERCHANT_ID'),
- 'public_key': os.environ.get('BRAINTREE_PUBLIC_KEY'),
- 'private_key': os.environ.get('BRAINTREE_PRIVATE_KEY')
+ "braintree": {
+ "module": "saleor.payment.gateways.braintree",
+ "connection_params": {
+ "sandbox_mode": get_bool_from_env("BRAINTREE_SANDBOX_MODE", True),
+ "merchant_id": os.environ.get("BRAINTREE_MERCHANT_ID"),
+ "public_key": os.environ.get("BRAINTREE_PUBLIC_KEY"),
+ "private_key": os.environ.get("BRAINTREE_PRIVATE_KEY"),
}
}
}
@@ -440,4 +449,3 @@ Tips
In such case, you might want to charge the customer 70 dollars, but due
to gateway misconfiguration, he will be charged 70 euros.
Such a situation should be handled, and adequate error should be thrown.
-