Skip to content

Commit 8f4cc0e

Browse files
authored
Add & Configure Flake8 (#10)
* changing after linting * add * change github action * fix github action * pip flake8 html * HTML retention day * pytest html report
1 parent 0e06c04 commit 8f4cc0e

File tree

13 files changed

+69
-18
lines changed

13 files changed

+69
-18
lines changed

.flake8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
format = html
3+
htmldir = flake8-report
4+
count = True
5+
max-complexity = 10
6+
statistics = True
7+
max-line-length = 127

.github/workflows/python-app.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,27 @@ jobs:
2626
- name: Install dependencies
2727
run: |
2828
python -m pip install --upgrade pip
29-
pip install flake8 pytest
29+
pip install flake8 flake8-html pytest pytest-html
3030
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3131
- name: Lint with flake8
3232
run: |
3333
# stop the build if there are Python syntax errors or undefined names
34-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --format=html --htmldir=flake8-report
3535
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --format=html --htmldir=flake8-report
37+
- name: Upload HTML Flake8 report
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: flake8-html-report
41+
path: flake8-report/
42+
retention-days: 1
3743
- name: Test with pytest
3844
run: |
39-
pytest -vv
45+
pytest -v --html=pytest-report.html --self-contained-html
46+
- name: Upload HTML Pytest report
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: pytest-html-report
50+
path: pytest-report.html
51+
retention-days: 1
52+

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,8 @@ cython_debug/
197197
.idea
198198

199199
# user generated files
200-
*output.log
200+
*output.log
201+
202+
# Flake8
203+
flake8-report
204+

src/asynchronous/runner/concurrent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from asynchronous.runner.task.myasynctask import custom_async_task
66
from asynchronous.runner.operation.myoperations import first_operation, second_operation
77

8+
89
# this coroutine runs both runner concurrently with asyncio.gather()
910
async def running_concurrently():
1011
await asyncio.gather(custom_async_task(first_operation, 3),
1112
custom_async_task(second_operation, 2))
1213

14+
1315
# starts the event loop, running and waiting for both runner to complete
1416
def main():
15-
asyncio.run(running_concurrently())
17+
asyncio.run(running_concurrently())

src/asynchronous/runner/operation/myoperations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
Definition of two simple operations.
33
"""
44

5+
56
def first_operation():
67
print("First operation")
78

9+
810
def second_operation():
911
print("Second operation")

src/asynchronous/runner/sequential.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
from asynchronous.runner.task.myasynctask import custom_async_task
66
from asynchronous.runner.operation.myoperations import first_operation, second_operation
77

8-
# runs two runner sequentially, waiting for one to finish before starting the next
8+
9+
# runs two runner sequentially, waiting for
10+
# one to finish before starting the next
911
async def running_sequentially():
1012
await custom_async_task(first_operation, 3)
1113
await custom_async_task(second_operation, 2)
1214

15+
1316
# executes both runner, totaling around 5 seconds of runtime
1417
def main():
1518
asyncio.run(running_sequentially())

src/asynchronous/runner/task/myasynctask.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22

3+
34
async def custom_async_task(func, sleep_time):
45
"""
56
Custom asynchronous task (coroutine)
@@ -9,4 +10,4 @@ async def custom_async_task(func, sleep_time):
910
print(f"Execution of {func.__name__} started")
1011
func()
1112
await asyncio.sleep(sleep_time)
12-
print(f"Execution of {func.__name__} completed")
13+
print(f"Execution of {func.__name__} completed")

src/asynchronous/tests/usage_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_sequential_run(mock_print):
1717

1818
mock_print.assert_has_calls(order_of_calls, any_order=False)
1919

20+
2021
@patch('builtins.print', create=True)
2122
def test_concurrent_run(mock_print):
2223
concurrent.main()

src/asynchronous/usage1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from asynchronous.runner import sequential
22

3-
sequential.main()
3+
4+
sequential.main()

src/asynchronous/usage2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from asynchronous.runner import concurrent
22

3-
concurrent.main()
3+
4+
concurrent.main()

0 commit comments

Comments
 (0)