Skip to content

Commit

Permalink
Add gh action for black (#1115)
Browse files Browse the repository at this point in the history
* Add gh action for black

* Black

* Remove black check from ci.yml
  • Loading branch information
tisto authored Apr 29, 2021
1 parent 6ef911d commit 2c859f6
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 22 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Black
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

steps:
# git checkout
- uses: actions/checkout@v2

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# install black
- name: install black
run: pip install black

# run black
- name: run black
run: black src/ --check --diff
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ jobs:
env:
CI: true

# black
- name: black
run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == '3.7' ]; then pip install black && black src/ --check --diff; fi

# code analysis
- name: code analysis
run: bin/code-analysis
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/controlpanels/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def delete(names):


class IDexterityTypesControlpanel(IControlpanel):
""" Dexterity Types Control panel """
"""Dexterity Types Control panel"""
16 changes: 8 additions & 8 deletions src/plone/restapi/deserializer/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,46 +215,46 @@ def __call__(self, block):
@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class ResolveUIDDeserializer(ResolveUIDDeserializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class ResolveUIDDeserializerRoot(ResolveUIDDeserializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""


@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class TextBlockDeserializer(TextBlockDeserializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class TextBlockDeserializerRoot(TextBlockDeserializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""


@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class HTMLBlockDeserializer(HTMLBlockDeserializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class HTMLBlockDeserializerRoot(HTMLBlockDeserializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""


@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class ImageBlockDeserializer(ImageBlockDeserializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class ImageBlockDeserializerRoot(ImageBlockDeserializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""
2 changes: 1 addition & 1 deletion src/plone/restapi/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class IExpandableElement(Interface):
"""

def __call__(expand=False):
""""""
""" """


class IZCatalogCompatibleQuery(Interface):
Expand Down
8 changes: 4 additions & 4 deletions src/plone/restapi/serializer/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ def __call__(self, value):
@implementer(IBlockFieldSerializationTransformer)
@adapter(IBlocks, IBrowserRequest)
class ResolveUIDSerializer(ResolveUIDSerializerBase):
""" Serializer for content-types with IBlocks behavior """
"""Serializer for content-types with IBlocks behavior"""


@implementer(IBlockFieldSerializationTransformer)
@adapter(IPloneSiteRoot, IBrowserRequest)
class ResolveUIDSerializerRoot(ResolveUIDSerializerBase):
""" Serializer for site root """
"""Serializer for site root"""


@implementer(IBlockFieldSerializationTransformer)
@adapter(IBlocks, IBrowserRequest)
class TextBlockSerializer(TextBlockSerializerBase):
""" Serializer for content-types with IBlocks behavior """
"""Serializer for content-types with IBlocks behavior"""


@implementer(IBlockFieldSerializationTransformer)
@adapter(IPloneSiteRoot, IBrowserRequest)
class TextBlockSerializerRoot(TextBlockSerializerBase):
""" Serializer for site root """
"""Serializer for site root"""
4 changes: 2 additions & 2 deletions src/plone/restapi/serializer/nextprev.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, context):

@property
def next(self):
""" return info about the next item in the container """
"""return info about the next item in the container"""
if getattr(self.parent, "_ordering", "") == "unordered":
# Unordered folder
return {}
Expand All @@ -47,7 +47,7 @@ def next(self):

@property
def previous(self):
""" return info about the previous item in the container """
"""return info about the previous item in the container"""
if getattr(self.parent, "_ordering", "") == "unordered":
# Unordered folder
return {}
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/tests/test_content_local_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_ac_local_roles_block(self, obj):
)

def test_sharing_search(self):
"""A request to @sharing should support the search parameter. """
"""A request to @sharing should support the search parameter."""
response = requests.get(
self.portal.folder1.absolute_url() + "/@sharing",
headers={"Accept": "application/json"},
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/tests/test_dxcontent_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def __call__(self, value, mime_type):
)

def test_allow_discussion_by_default(self):
""" Not globally addable, not fti enabled, not obj instance enabled """
"""Not globally addable, not fti enabled, not obj instance enabled"""
self.portal.invokeFactory("Document", id=u"doc2")
serializer = getMultiAdapter((self.portal.doc2, self.request), ISerializeToJson)
obj = serializer()
Expand Down

0 comments on commit 2c859f6

Please sign in to comment.