Skip to content

Commit

Permalink
Merge pull request #4660 from NyanKiyoshi/pydocstyle/travis-check
Browse files Browse the repository at this point in the history
Added travis check for pydocstyle
  • Loading branch information
korycins committed Aug 20, 2019
2 parents de8091e + 9af9b4d commit 3c6c3a0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions saleor/core/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ def get_db_prep_save(self, value: dict, connection):


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)
Expand Down
19 changes: 12 additions & 7 deletions saleor/graphql/core/utils/reordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

@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
Expand Down Expand Up @@ -58,11 +60,12 @@ def ordered_node_map(self):
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)
Expand Down Expand Up @@ -153,7 +156,9 @@ def run(self):


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.
Expand Down
5 changes: 2 additions & 3 deletions saleor/graphql/product/mutations/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def check_permissions(cls, user):

@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 = []

Expand Down Expand Up @@ -363,8 +363,7 @@ def check_product_operations_are_assignable(cls, product_attrs_pks):

@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
Expand Down
6 changes: 4 additions & 2 deletions saleor/graphql/product/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
6 changes: 4 additions & 2 deletions saleor/product/utils/variants_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@


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 = {}

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c6c3a0

Please sign in to comment.