Skip to content

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

Added travis check for pydocstyle

NyanKiyoshi9af9b4d78a24
diff --git a/.travis.yml b/.travis.yml
index 8634b93c89..d931d090d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,6 +53,8 @@ matrix:
python: "3.6"
- env: TOXENV=check_migrations
python: "3.6"
+ - env: TOXENV=pydocstyle
+ python: "3.6"
allow_failures:
- python: "3.6"
env: DJANGO="master"
diff --git a/saleor/core/fields.py b/saleor/core/fields.py
index 9458c20aa1..a156bbcd8f 100644
--- a/saleor/core/fields.py
+++ b/saleor/core/fields.py
@@ -28,13 +28,16 @@ class SanitizedJSONField(JSONField):
class FilterableJSONBField(jsonb.JSONField):
- """This only redefine the JSONB field of django to register a custom lookup key
+ """A JSONB field with filtering support over numerical keys.
+
+ This only redefine the JSONB field of django to register a custom lookup key
that allow us to filter JSONB field by key value no matter what. Where django's
behavior is to filter by key index position if the lookup value is a string number.
This is a temporary fix waiting for a fix from django.
- Refer to https://code.djangoproject.com/ticket/30566."""
+ Refer to https://code.djangoproject.com/ticket/30566.
+ """
_FROM_KEY_LOOKUP = "from_key_"
_FROM_KEY_LOOKUP_LEN = len(_FROM_KEY_LOOKUP)
diff --git a/saleor/graphql/core/utils/reordering.py b/saleor/graphql/core/utils/reordering.py
index e3a8d56770..c341625540 100644
--- a/saleor/graphql/core/utils/reordering.py
+++ b/saleor/graphql/core/utils/reordering.py
@@ -12,8 +12,10 @@ __all__ = ["perform_reordering"]
@dataclass(frozen=True)
class FinalSortOrder:
- """Describes a final sort order value for a given PK. This is needed to tell django
- which objects and values to associate and update."""
+ """Describe a final sort order value for a given PK.
+
+ This is needed to tell django which objects and values to associate and update.
+ """
pk: int
sort_order: int
@@ -58,11 +60,12 @@ class Reordering:
return ordering_map
def calculate_new_sort_order(self, pk, move) -> Tuple[int, int, int]:
- """Returns the proper sort order for the current operation to properly
- move the node in a given direction with by amount.
+ """Return the proper sort order for the current operation.
- This ensures the new sort order is not biased from gaps between
- the sort orders."""
+ Allows to properly move the node in a given direction with by amount.
+
+ This ensures the new sort order is not biased from gaps between the sort orders.
+ """
# Retrieve the position of the node to move
node_pos = self.ordered_pks.index(pk)
@@ -153,7 +156,9 @@ class Reordering:
def perform_reordering(qs: QuerySet, operations: Dict[int, int], field: str = "moves"):
- """This utility takes a set of operations containing a node
+ """Perform reordering over given operations on a queryset.
+
+ This utility takes a set of operations containing a node
and a relative sort order. It then converts the relative sorting
to an absolute sorting.
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index b7934d1f9d..006604ebec 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -297,7 +297,7 @@ class AttributeAssign(BaseMutation):
@classmethod
def get_operations(cls, info, operations: List[AttributeAssignInput]):
- """Resolves all passed global ids into integer PKs of the Attribute type."""
+ """Resolve all passed global ids into integer PKs of the Attribute type."""
product_attrs_pks = []
variant_attrs_pks = []
@@ -363,8 +363,7 @@ class AttributeAssign(BaseMutation):
@classmethod
def clean_operations(cls, product_type, product_attrs_pks, variant_attrs_pks):
- """Ensures the requested attributes are not already assigned
- to that product type."""
+ """Ensure the attributes are not already assigned to the product type."""
cls.check_product_operations_are_assignable(product_attrs_pks)
cls.check_operations_not_assigned_already(
product_type, product_attrs_pks, variant_attrs_pks
diff --git a/saleor/graphql/product/utils.py b/saleor/graphql/product/utils.py
index 7ccbfa58ce..302ccaeffb 100644
--- a/saleor/graphql/product/utils.py
+++ b/saleor/graphql/product/utils.py
@@ -26,8 +26,10 @@ def _resolve_attributes_input(
attributes_map_by_slug: attribute_map_type,
attributes_map_by_id: attribute_map_type,
) -> attribute_input_type:
- """This resolves a raw GraphQL input to proper attribute. Its job is to ensure
- a backward compatibility with passing attributes by slug."""
+ """Resolve a raw GraphQL input to proper attribute.
+
+ Its job is to ensure a backward compatibility with passing attributes by slug.
+ """
resolved_input = [] # type: List[ResolvedAttributeInput]
diff --git a/saleor/product/utils/variants_picker.py b/saleor/product/utils/variants_picker.py
index b1fc2d0c5a..2a72c8ba14 100644
--- a/saleor/product/utils/variants_picker.py
+++ b/saleor/product/utils/variants_picker.py
@@ -13,9 +13,11 @@ from .availability import get_product_availability
def _attributes_to_single(attributes: Dict[str, List[str]]) -> Dict[str, str]:
- """This converts nested attributes to a flat attribute ({attr_pk: val_pk}).
+ """Convert nested attributes to a flat attribute ({attr_pk: val_pk}).
+
This is used for backward compatibility between the storefront 1.0
- and dashboard 2.0's new attribute mechanism."""
+ and dashboard 2.0's new attribute mechanism.
+ """
new_attributes = {}
diff --git a/tox.ini b/tox.ini
index 0d27dc9d8c..34d6f67637 100644
--- a/tox.ini
+++ b/tox.ini
@@ -32,11 +32,11 @@ commands =
[testenv:pydocstyle]
basepython = python3.6
-whitelist_externals = find
+whitelist_externals = sh
deps =
pydocstyle>=4.0.0
commands =
- pydocstyle $(find saleor -name '*.py' -type f) -v
+ sh -c 'find saleor -name "*.py" -type f | xargs pydocstyle -v'
[testenv:check_gql_schema]
basepython = python3.6