Skip to content

Commit b365c15

Browse files
committed
ci: add ruff and flake8 linters GitHub workflow
1 parent f9fd086 commit b365c15

4 files changed

Lines changed: 36 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ jobs:
1717
uses: actions/setup-python@v5
1818
with:
1919
python-version: ${{ matrix.python-version }}
20-
- name: Install dependencies
21-
run: |
22-
python3 -m pip install flake8
2320
- name: Unit tests
2421
run: |
2522
python3 -m unittest -v
26-
- name: PEP8
27-
run: |
28-
flake8 --max-line-length 120

.github/workflows/linters.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Linters
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
jobs:
7+
linters:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Install Python
12+
uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.13"
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install ruff flake8
19+
- name: Run Ruff
20+
run: ruff check --output-format=github .
21+
- name: Run Flake8
22+
run: flake8 --max-line-length 120

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
__pycache__
2+
.ruff_cache
13
.venv
2-
*.pyc
34
*.egg-info
45
*.eggs
5-
dist
6+
*.pyc
67
build
8+
dist
79
MANIFEST
8-
__pycache__

tests/test_kanboard.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,33 @@
2929

3030

3131
class TestClient(unittest.TestCase):
32-
3332
def setUp(self):
34-
self.url = 'some api url'
35-
self.client = kanboard.Client(self.url, 'username', 'password')
33+
self.url = "some api url"
34+
self.client = kanboard.Client(self.url, "username", "password")
3635
self.request, self.urlopen = self._create_mocks()
3736

3837
def ignore_warnings(test_func):
3938
def do_test(self, *args, **kwargs):
4039
with warnings.catch_warnings():
4140
warnings.simplefilter("ignore")
4241
test_func(self, *args, **kwargs)
42+
4343
return do_test
4444

4545
def test_api_call(self):
4646
body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
4747
self.urlopen.return_value.read.return_value = body
4848
self.assertEqual(True, self.client.remote_procedure())
49-
self.request.assert_called_once_with(self.url,
50-
data=mock.ANY,
51-
headers=mock.ANY)
49+
self.request.assert_called_once_with(self.url, data=mock.ANY, headers=mock.ANY)
5250

5351
def test_custom_auth_header(self):
54-
self.client._auth_header = 'X-Auth-Header'
52+
self.client._auth_header = "X-Auth-Header"
5553
body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
5654
self.urlopen.return_value.read.return_value = body
5755
self.assertEqual(True, self.client.remote_procedure())
58-
self.request.assert_called_once_with(self.url,
59-
data=mock.ANY,
60-
headers=mock.ANY)
56+
self.request.assert_called_once_with(self.url, data=mock.ANY, headers=mock.ANY)
6157
_, kwargs = self.request.call_args
62-
assert kwargs['headers']['X-Auth-Header'] == 'dXNlcm5hbWU6cGFzc3dvcmQ='
58+
assert kwargs["headers"]["X-Auth-Header"] == "dXNlcm5hbWU6cGFzc3dvcmQ="
6359

6460
def test_http_error(self):
6561
self.urlopen.side_effect = Exception()
@@ -70,7 +66,7 @@ def test_application_error(self):
7066
body = b'{"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 123}'
7167
self.urlopen.return_value.read.return_value = body
7268

73-
with self.assertRaises(kanboard.ClientError, msg='Internal error'):
69+
with self.assertRaises(kanboard.ClientError, msg="Internal error"):
7470
self.client.remote_procedure()
7571

7672
def test_async_method_call_recognised(self):
@@ -98,6 +94,6 @@ def test_async_call_generates_coro(self):
9894

9995
@staticmethod
10096
def _create_mocks():
101-
request_patcher = mock.patch('urllib.request.Request')
102-
urlopen_patcher = mock.patch('urllib.request.urlopen')
97+
request_patcher = mock.patch("urllib.request.Request")
98+
urlopen_patcher = mock.patch("urllib.request.urlopen")
10399
return request_patcher.start(), urlopen_patcher.start()

0 commit comments

Comments
 (0)