Skip to content

Commit 25befdc

Browse files
committed
add precommit
1 parent f293d70 commit 25befdc

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
lines changed

.github/workflows/lint.yml

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,74 +20,51 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v3
23-
- name: Get changed Python files
24-
id: changed-py-files
25-
uses: tj-actions/changed-files@v23
26-
with:
27-
files: |
28-
*.py
29-
**/*.py
3023
- uses: chartboost/ruff-action@v1
31-
if: steps.changed-py-files.outputs.any_changed == 'true'
3224
with:
3325
version: 0.3.5
3426
args: 'format --check --config ./ruff.toml'
35-
src: ${{ steps.changed-py-files.outputs.all_changed_files }}
3627

3728
ruff-isort:
3829
needs: [ ]
3930
runs-on: ubuntu-latest
4031
steps:
4132
- uses: actions/checkout@v3
42-
- name: Get changed Python files
43-
id: changed-py-files
44-
uses: tj-actions/changed-files@v23
45-
with:
46-
files: |
47-
*.py
48-
**/*.py
4933
- uses: chartboost/ruff-action@v1
50-
if: steps.changed-py-files.outputs.any_changed == 'true'
5134
with:
5235
version: 0.3.5
5336
args: '--select I --config ./ruff.toml'
54-
src: ${{ steps.changed-py-files.outputs.all_changed_files }}
5537

5638
ruff:
5739
needs: []
5840
runs-on: ubuntu-latest
5941
steps:
6042
- uses: actions/checkout@v3
61-
- name: Get changed Python files
62-
id: changed-py-files
63-
uses: tj-actions/changed-files@v23
64-
with:
65-
files: |
66-
*.py
67-
**/*.py
6843
- uses: chartboost/ruff-action@v1
69-
if: steps.changed-py-files.outputs.any_changed == 'true'
7044
with:
7145
version: 0.3.5
7246
args: '--config ./ruff.toml'
73-
src: ${{ steps.changed-py-files.outputs.all_changed_files }}
7447

7548
mypy:
49+
needs: []
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
- uses: actions/setup-python@v4
54+
with:
55+
python-version: '3.9'
56+
- run: pip install mypy==1.5.1
57+
- run: mypy
58+
59+
pre-commit:
7660
needs: []
7761
runs-on: ubuntu-latest
7862
steps:
7963
- uses: actions/checkout@v3
8064
- uses: actions/setup-python@v4
8165
with:
8266
python-version: '3.9'
83-
- run: pip install mypy==1.5.1
84-
- name: Get changed Python files
85-
id: changed-py-files
86-
uses: tj-actions/changed-files@v23
87-
with:
88-
files: |
89-
*.py
90-
**/*.py
91-
- name: Run if any of the listed files above is changed
92-
if: steps.changed-py-files.outputs.any_changed == 'true'
93-
run: mypy ${{ steps.changed-py-files.outputs.all_changed_files }}
67+
- uses: pre-commit/action@v3.0.0
68+
name: pre-commit
69+
env:
70+
SKIP: ruff,ruff-format,ruff-isort

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
# python specific hooks
5+
- repo: https://github.com/astral-sh/ruff-pre-commit
6+
# Ruff version.
7+
rev: v0.3.5
8+
hooks:
9+
# Run the linter.
10+
- id: ruff
11+
args: [--no-cache, --config=./ruff.toml]
12+
- id: ruff
13+
alias: ruff-isort
14+
name: ruff-isort
15+
args: [--fix, --select=I, --no-cache, --config=./ruff.toml]
16+
- id: ruff-format
17+
args: [--no-cache, --config=./ruff.toml]

ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[lint]
2-
32
# Enable default rules plus S101 (check for asserts).
43
select = ["E4", "E7", "E9", "F", "S101"]
54

0 commit comments

Comments
 (0)