diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e433eb8c..8b784fd9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,6 @@ -name: Lints +name: Styling and lints on: [push, pull_request] + jobs: lint: name: Run lints @@ -8,8 +9,8 @@ jobs: - uses: actions/checkout@v6 - name: Run ruff uses: astral-sh/ruff-action@v3 - src: >- - kernels + with: + src: kernels/src kernels/tests black: name: Run black check @@ -24,12 +25,24 @@ jobs: with: python-version: 3.12 - - name: Install black - run: uv pip install black - - name: Check formatting - run: | - uv run black --check kernels + run: uv run --with black black --check kernels/src kernels/tests + + isort: + name: Run isort check + runs-on: ubuntu-latest + env: + UV_PYTHON_PREFERENCE: only-managed + steps: + - uses: actions/checkout@v6 + + - name: Install uv and set the python version + uses: astral-sh/setup-uv@v7 + with: + python-version: 3.12 + + - name: Check import sorting + run: uv run --with isort isort --check-only --diff kernels/src kernels/tests validate-dependencies: name: Validate python_depends.json @@ -44,7 +57,7 @@ jobs: - name: Validate python_depends.json is up-to-date run: | - python ( cd kernels && update_python_depends.py --validate ) || { + (cd kernels && python update_python_depends.py --validate) || { echo "Error: python_depends.json is out of date." echo "Please run: python update_python_depends.py" exit 1 diff --git a/kernels/Makefile b/kernels/Makefile index 580f53ab..94fcf78c 100644 --- a/kernels/Makefile +++ b/kernels/Makefile @@ -1,4 +1,4 @@ -.PHONY: style +.PHONY: style quality export check_dirs := src tests @@ -11,3 +11,8 @@ style: black ${check_dirs} isort ${check_dirs} ruff check ${check_dirs} --fix + +quality: + black --check ${check_dirs} + isort --check-only --diff ${check_dirs} + ruff check ${check_dirs} diff --git a/kernels/tests/test_layer.py b/kernels/tests/test_layer.py index ca804e8c..e9988fd3 100644 --- a/kernels/tests/test_layer.py +++ b/kernels/tests/test_layer.py @@ -102,7 +102,6 @@ def __init__(self): def forward(self, input: torch.Tensor) -> torch.Tensor: self.n_calls += 1 - _ = input.shape[-1] // 2 return F.relu(input)