Skip to content

Commit 0d0b8f6

Browse files
author
Sergey Vilgelm
committed
Remove flake8 validation and add black instead
Add a `checks` job in workflow to do a preliminary checks
1 parent 312a540 commit 0d0b8f6

File tree

7 files changed

+40
-23
lines changed

7 files changed

+40
-23
lines changed

.github/workflows/test.yml

+27-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,31 @@ on:
99
schedule:
1010
- cron: "0 1 * * *"
1111
jobs:
12-
test:
12+
checks:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set up Python 3.8
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.8
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install ".[dev]"
25+
- name: Format with black
26+
run: |
27+
if ! RES=$(black --check $(git diff --name-only --diff-filter=AM master -- "*.py") 2>&1); then
28+
RES="${RES//'%'/'%25'}"
29+
RES="${RES//$'\n'/'%0A'}"
30+
RES="${RES//$'\r'/'%0D'}"
31+
echo "::error ::${RES}"
32+
exit 1
33+
fi
34+
echo ${RES}
35+
unit-tests:
36+
needs: checks
1337
runs-on: ubuntu-latest
1438
strategy:
1539
matrix:
@@ -24,7 +48,7 @@ jobs:
2448
- name: Install dependencies
2549
run: |
2650
python -m pip install --upgrade pip
27-
pip install ".[dev]"
51+
pip install ".[test]"
2852
- name: Test with inv
2953
run: inv cover qa
3054
- name: Coveralls
@@ -35,7 +59,7 @@ jobs:
3559
env:
3660
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
3761
bench:
38-
needs: test
62+
needs: unit-tests
3963
runs-on: ubuntu-latest
4064
if: github.event_name == 'pull_request'
4165
steps:

CONTRIBUTING.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ There are some rules to follow:
4141

4242
- your contribution should be documented (if needed)
4343
- your contribution should be tested and the test suite should pass successfully
44-
- your code should be mostly PEP8 compatible with a 120 characters line length
44+
- your code should be properly formatted (use ``black .`` to format)
4545
- your contribution should support both Python 2 and 3 (use ``tox`` to test)
4646

4747
You need to install some dependencies to develop on flask-restx:

README.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ Flask RESTX
1818
:target: https://pypi.org/project/flask-restx
1919
:alt: Supported Python versions
2020
.. image:: https://badges.gitter.im/Join%20Chat.svg
21-
:alt: Join the chat at https://gitter.im/python-restx
22-
:target: https://gitter.im/python-restx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
21+
:target: https://gitter.im/python-restx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
22+
:alt: Join the chat at https://gitter.im/python-restx
23+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
24+
:target: https://github.com/psf/black
25+
:alt: Code style: black
2326

2427

2528
Flask-RESTX is a community driven fork of `Flask-RESTPlus <https://github.com/noirbizarre/flask-restplus>`_.

requirements/develop.pip

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
invoke==1.3.0
2-
flake8==3.7.8
3-
readme-renderer==24.0
41
tox==3.13.2
5-
twine==1.15.0
2+
black==19.10b0; python_version >= '3.6'

requirements/test.pip

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ pytest-mock==1.10.4
1010
pytest-profiling==1.7.0
1111
pytest-sugar==0.9.2
1212
tzlocal
13+
14+
invoke==1.3.0
15+
readme-renderer==24.0
16+
twine==1.15.0

setup.cfg

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
[flake8]
2-
ignore = E124,E128
3-
max-line-length = 120
4-
exclude = doc,.git
5-
61
[bdist_wheel]
72
universal = 1
83

tasks.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ def qa(ctx):
150150
'''Run a quality report'''
151151
header(qa.__doc__)
152152
with ctx.cd(ROOT):
153-
info('Python Static Analysis')
154-
flake8_results = ctx.run('flake8 flask_restx tests', pty=True, warn=True)
155-
if flake8_results.failed:
156-
error('There is some lints to fix')
157-
else:
158-
success('No linter errors')
159153
info('Ensure PyPI can render README and CHANGELOG')
160154
info('Building dist package')
161155
dist = ctx.run('python setup.py sdist', pty=True, warn=False, hide=True)
@@ -168,8 +162,8 @@ def qa(ctx):
168162
error('README and/or CHANGELOG is not renderable by PyPI')
169163
else:
170164
success('README and CHANGELOG are renderable by PyPI')
171-
if flake8_results.failed or readme_results.failed:
172-
exit('Quality check failed', flake8_results.return_code or readme_results.return_code)
165+
if readme_results.failed:
166+
exit('Quality check failed', readme_results.return_code)
173167
success('Quality check OK')
174168

175169

0 commit comments

Comments
 (0)