Skip to content

Commit 03c641a

Browse files
authored
Enable Python Linter (mlc-ai#1098)
This PR enables two Python formatters "black" and "isort" on the following directory: - `./python/` - `./tests/python/` Enabling pylint and mypy is left for future work
1 parent e9b85ce commit 03c641a

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.github/workflows/python_lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Python Lint
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
IMAGE: 'mlcaidev/ci-cpu:8a87699'
7+
8+
jobs:
9+
isort:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
submodules: 'recursive'
15+
- name: Version
16+
run: |
17+
wget https://raw.githubusercontent.com/mlc-ai/package/main/docker/bash.sh -O ./ci/bash.sh
18+
chmod u+x ./ci/bash.sh
19+
./ci/bash.sh $IMAGE "conda env export --name ci-lint"
20+
- name: Lint
21+
run: |
22+
./ci/bash.sh $IMAGE bash ./ci/task/isort.sh
23+
24+
black:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
with:
29+
submodules: 'recursive'
30+
- name: Version
31+
run: |
32+
wget https://raw.githubusercontent.com/mlc-ai/package/main/docker/bash.sh -O ./ci/bash.sh
33+
chmod u+x ./ci/bash.sh
34+
./ci/bash.sh $IMAGE "conda env export --name ci-lint"
35+
- name: Lint
36+
run: |
37+
./ci/bash.sh $IMAGE bash ./ci/task/black.sh

ci/task/black.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
source ~/.bashrc
5+
micromamba activate ci-lint
6+
NUM_THREADS=$(nproc)
7+
8+
black --check --workers $NUM_THREADS ./python/
9+
black --check --workers $NUM_THREADS ./tests/python

ci/task/isort.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
source ~/.bashrc
5+
micromamba activate ci-lint
6+
NUM_THREADS=$(nproc)
7+
8+
isort --check-only -j $NUM_THREADS --profile black ./python/
9+
isort --check-only -j $NUM_THREADS --profile black ./tests/python/

0 commit comments

Comments
 (0)