Skip to content

Commit c658ee5

Browse files
authored
introduce automatic pylint to CI (Netflix#316)
* introduce automatic pylint to CI * Tox is the way
1 parent fdea8f1 commit c658ee5

File tree

7 files changed

+35
-4
lines changed

7 files changed

+35
-4
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,27 @@ jobs:
2626
python -m pip install pycodestyle
2727
- name: Run Python PEP8 code style checks
2828
run: pycodestyle
29-
29+
30+
pylint:
31+
runs-on: ubuntu-latest
32+
33+
strategy:
34+
matrix:
35+
python-version: [3.7]
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Set up Python ${{ matrix.python-version }}
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
- name: Install Python ${{ matrix.python-version }} dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
python -m pip install tox pylint
47+
- name: Run Tox (pylint)
48+
run: tox -e pylint
49+
3050
unit:
3151
runs-on: ubuntu-latest
3252

services/ui_backend_service/data/cache/client/cache_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,6 @@ def cli(root=None,
299299

300300

301301
if __name__ == '__main__':
302+
# Click magic
303+
# pylint: disable=unexpected-keyword-arg
302304
cli(auto_envvar_prefix='MFCACHE')

services/ui_backend_service/data/cache/store.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ async def preload_dag(self, flow_name: str, run_number: str):
314314
"""
315315
logger.debug(" - Preload DAG for {}/{}".format(flow_name, run_number))
316316
# Check first if a DAG can be generated for the run.
317+
# pylint-initial-ignore: Not sure where db comes from
318+
# pylint: disable=no-member
317319
db_response = await get_run_dag_data(self.db, flow_name, run_number)
318320

319321
if not db_response.response_code == 200:
@@ -322,6 +324,8 @@ async def preload_dag(self, flow_name: str, run_number: str):
322324
# Prefer run_id over run_number
323325
run_id = db_response.body.get('run_id') or db_response.body['run_number']
324326

327+
# pylint-initial-ignore: Not sure where GenerateDag comes from
328+
# pylint: disable=no-member
325329
res = await self.cache.GenerateDag(flow_name, run_id)
326330
async for event in res.stream():
327331
if event["type"] == "error":

services/ui_backend_service/data/db/tables/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ async def execute_sql(self, select_sql: str, values=[], fetch_single=False,
230230
records = await cur.fetchall()
231231
if serialize:
232232
for record in records:
233+
# pylint-initial-ignore: Lack of __init__ makes this too hard for pylint
234+
# pylint: disable=not-callable
233235
row = self._row_type(**record)
234236
rows.append(row.serialize(expanded))
235237
else:

services/ui_backend_service/tests/integration_tests/log_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ async def read_and_output(cache_client, task, logtype, limit=0, page=1, reverse_
6969
_, data = await _test_list_resources(cli, db, "/flows/{flow_id}/runs/{run_number}/steps/{step_name}/tasks/{task_id}/logs/out?_limit=3".format(**_task), 200, None)
7070
assert data == []
7171

72-
async def read_and_output(cache_client, task, logtype, limit=0, page=1, reverse_order=False, output_raw=False):
72+
async def read_and_output_2(cache_client, task, logtype, limit=0, page=1, reverse_order=False, output_raw=False):
7373
assert limit == 3
7474
assert page == 4
7575
assert reverse_order is True
7676
assert output_raw is False
7777
return [], 1
7878

79-
with mock.patch("services.ui_backend_service.api.log.read_and_output", new=read_and_output):
79+
with mock.patch("services.ui_backend_service.api.log.read_and_output", new=read_and_output_2):
8080
# ordering by row should be possible in reverse. should obey limit.
8181
_, data = await _test_list_resources(cli, db, "/flows/{flow_id}/runs/{run_number}/steps/{step_name}/tasks/{task_id}/logs/out?_order=-row&_limit=3&_page=4".format(**_task), 200, None)
8282
assert data == []

services/ui_backend_service/tests/unit_tests/cache_utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _raised(output):
7878
assert str(ex) == "Custom exception"
7979

8080

81-
def test_streamed_errors_exception_output():
81+
def test_streamed_errors_exception_output_no_re_raise():
8282
# should not raise any exception with re_raise set to false.
8383
def _re_raise(output):
8484
pass

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ commands = pytest --cov=services
99
passenv = MF_METADATA_DB_HOST MF_METADATA_DB_PORT MF_METADATA_DB_USER MF_METADATA_DB_PSWD MF_METADATA_DB_NAME MF_UI_METADATA_PORT MF_UI_METADATA_HOST
1010
extras = tests
1111

12+
[testenv:pylint]
13+
commands = pylint -E services --ignored-modules=psycopg2.errors,pygit2
14+
1215
[testenv:unit]
1316
commands = pytest --cov=services -m unit_tests
1417

0 commit comments

Comments
 (0)