Skip to content

Commit

Permalink
Enable Python Linter (mlc-ai#1098)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
junrushao authored Oct 21, 2023
1 parent e9b85ce commit 03c641a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python Lint

on: [push, pull_request]

env:
IMAGE: 'mlcaidev/ci-cpu:8a87699'

jobs:
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Version
run: |
wget https://raw.githubusercontent.com/mlc-ai/package/main/docker/bash.sh -O ./ci/bash.sh
chmod u+x ./ci/bash.sh
./ci/bash.sh $IMAGE "conda env export --name ci-lint"
- name: Lint
run: |
./ci/bash.sh $IMAGE bash ./ci/task/isort.sh
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Version
run: |
wget https://raw.githubusercontent.com/mlc-ai/package/main/docker/bash.sh -O ./ci/bash.sh
chmod u+x ./ci/bash.sh
./ci/bash.sh $IMAGE "conda env export --name ci-lint"
- name: Lint
run: |
./ci/bash.sh $IMAGE bash ./ci/task/black.sh
9 changes: 9 additions & 0 deletions ci/task/black.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -eo pipefail

source ~/.bashrc
micromamba activate ci-lint
NUM_THREADS=$(nproc)

black --check --workers $NUM_THREADS ./python/
black --check --workers $NUM_THREADS ./tests/python
9 changes: 9 additions & 0 deletions ci/task/isort.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -eo pipefail

source ~/.bashrc
micromamba activate ci-lint
NUM_THREADS=$(nproc)

isort --check-only -j $NUM_THREADS --profile black ./python/
isort --check-only -j $NUM_THREADS --profile black ./tests/python/

0 comments on commit 03c641a

Please sign in to comment.