Skip to content

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

Add Flake8 as check action

NyanKiyoshi81fa485ada7a
diff --git a/.github/main.workflow b/.github/main.workflow
index e6e6d6d1a2..6e5c93259f 100644
--- a/.github/main.workflow
+++ b/.github/main.workflow
@@ -1,9 +1,30 @@
workflow "Linters" {
on = "push"
- resolves = ["Black Linter"]
+ resolves = ["Black Linter", "Flake8 Linter"]
+}
+
+action "Build" {
+ uses = "jefftriplett/python-actions@ba888adab5b57956dce82b7dfc06e87b65090a6d"
+ args = "pip install flake8 black"
+ env = {
+ VENV_DIR = "/opt/"
+ }
}
action "Black Linter" {
- uses = "lgeiger/black-action@4379f39aa4b6a3bb1cceb46a7665b9c26647d82d"
- args = ". --check"
+ uses = "jefftriplett/python-actions@ba888adab5b57956dce82b7dfc06e87b65090a6d"
+ args = "black --check saleor tests"
+ needs = ["Build"]
+ env = {
+ VENV_DIR = "/opt/"
+ }
+}
+
+action "Flake8 Linter" {
+ uses = "jefftriplett/python-actions@ba888adab5b57956dce82b7dfc06e87b65090a6d"
+ args = "flake8 saleor tests"
+ needs = ["Build"]
+ env = {
+ VENV_DIR = "/opt/"
+ }
}
diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.py
index e134bfeef0..d340725175 100644
--- a/saleor/checkout/views/summary.py
+++ b/saleor/checkout/views/summary.py
@@ -58,7 +58,7 @@ def summary_with_shipping_view(request, checkout):
checkout.user.addresses.all() if checkout.user else Address.objects.none()
)
- addresses_form, address_form, updated = update_billing_address_in_checkout_with_shipping(
+ addresses_form, address_form, updated = update_billing_address_in_checkout_with_shipping( # noqa
checkout, user_addresses, request.POST or None, request.country
)
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 17d7c6932c..85116d8fbc 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -824,8 +824,13 @@ def add_address_to_admin(email):
def create_page():
content = """
<h2>E-commerce for the PWA era</h2>
- <h3>A modular, high performance e-commerce storefront built with GraphQL, Django, and ReactJS.</h3>
- <p>Saleor is a rapidly-growing open source e-commerce platform that has served high-volume companies from branches like publishing and apparel since 2012. Based on Python and Django, the latest major update introduces a modular front end with a GraphQL API and storefront and dashboard written in React to make Saleor a full-functionality open source e-commerce.</p>
+ <h3>A modular, high performance e-commerce storefront built with GraphQL,
+ Django, and ReactJS.</h3>
+ <p>Saleor is a rapidly-growing open source e-commerce platform that has served
+ high-volume companies from branches like publishing and apparel since 2012.
+ Based on Python and Django, the latest major update introduces a modular
+ front end with a GraphQL API and storefront and dashboard written in React
+ to make Saleor a full-functionality open source e-commerce.</p>
<p><a href="https://github.com/mirumee/saleor">Get Saleor today!</a></p>
"""
content_json = {
@@ -842,7 +847,8 @@ def create_page():
{
"key": "",
"data": {},
- "text": "A modular, high performance e-commerce storefront built with GraphQL, Django, and ReactJS.",
+ "text": "A modular, high performance e-commerce storefront "
+ "built with GraphQL, Django, and ReactJS.",
"type": "unstyled",
"depth": 0,
"entityRanges": [],
@@ -860,7 +866,13 @@ def create_page():
{
"key": "",
"data": {},
- "text": "Saleor is a rapidly-growing open source e-commerce platform that has served high-volume companies from branches like publishing and apparel since 2012. Based on Python and Django, the latest major update introduces a modular front end with a GraphQL API and storefront and dashboard written in React to make Saleor a full-functionality open source e-commerce.",
+ "text": "Saleor is a rapidly-growing open source e-commerce platform "
+ "that has served high-volume companies from branches like "
+ "publishing and apparel since 2012. Based on Python and "
+ "Django, the latest major update introduces a modular "
+ "front end with a GraphQL API and storefront and dashboard "
+ "written in React to make Saleor a full-functionality "
+ "open source e-commerce.",
"type": "unstyled",
"depth": 0,
"entityRanges": [],
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py
index fdd54dc0e2..a890a4733a 100644
--- a/saleor/dashboard/product/forms.py
+++ b/saleor/dashboard/product/forms.py
@@ -385,9 +385,8 @@ class ProductVariantForm(forms.ModelForm, AttributesMixin):
self.fields["price_override"].widget.attrs[
"placeholder"
] = self.instance.product.price.amount
- self.available_attributes = self.instance.product.product_type.variant_attributes.all().prefetch_related(
- "values"
- )
+ qs = self.instance.product.product_type.variant_attributes.all()
+ self.available_attributes = qs.prefetch_related("values")
self.prepare_fields_for_attributes()
if include_taxes_in_prices():
diff --git a/saleor/graphql/account/__init__.py b/saleor/graphql/account/__init__.py
index 7354438930..3fba9aefb3 100644
--- a/saleor/graphql/account/__init__.py
+++ b/saleor/graphql/account/__init__.py
@@ -1 +1,2 @@
+# flake8: noqa
from . import fields
diff --git a/saleor/graphql/core/__init__.py b/saleor/graphql/core/__init__.py
index 7354438930..e069383dca 100644
--- a/saleor/graphql/core/__init__.py
+++ b/saleor/graphql/core/__init__.py
@@ -1 +1 @@
-from . import fields
+from . import fields # noqa
diff --git a/saleor/graphql/core/types/__init__.py b/saleor/graphql/core/types/__init__.py
index 19a2edb59e..3ea384e89d 100644
--- a/saleor/graphql/core/types/__init__.py
+++ b/saleor/graphql/core/types/__init__.py
@@ -1,3 +1,4 @@
+# flake8: noqa
from .common import (
CountryDisplay,
Error,
diff --git a/saleor/graphql/product/types/__init__.py b/saleor/graphql/product/types/__init__.py
index 433abcd553..0c13108754 100644
--- a/saleor/graphql/product/types/__init__.py
+++ b/saleor/graphql/product/types/__init__.py
@@ -1,3 +1,4 @@
+# flake8: noqa
from .attributes import Attribute, AttributeValue, SelectedAttribute
from .digital_contents import DigitalContent, DigitalContentUrl
from .products import (
diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.py
index fbdfc9dead..1f9eeca8c2 100644
--- a/saleor/graphql/shipping/mutations.py
+++ b/saleor/graphql/shipping/mutations.py
@@ -116,8 +116,10 @@ class ShippingPriceMixin:
):
raise ValidationError(
{
- "maximum_order_price": "Maximum order price should be larger than the "
- "minimum order price."
+ "maximum_order_price": (
+ "Maximum order price should be larger than "
+ "the minimum order price."
+ )
}
)
else:
@@ -130,8 +132,10 @@ class ShippingPriceMixin:
):
raise ValidationError(
{
- "maximum_order_weight": "Maximum order weight should be larger than the "
- "minimum order weight."
+ "maximum_order_weight": (
+ "Maximum order weight should be larger than the "
+ "minimum order weight."
+ )
}
)
return cleaned_input
diff --git a/saleor/site/context_processors.py b/saleor/site/context_processors.py
index f5c2c79860..1b1beb114b 100644
--- a/saleor/site/context_processors.py
+++ b/saleor/site/context_processors.py
@@ -1,3 +1,4 @@
+import django.http.request
from django.contrib.sites.shortcuts import get_current_site
from django.db.models import prefetch_related_objects