Skip to content

Commit a8b9faf

Browse files
authored
Added pre-commit (#293)
* Added pre-commit config * Make CI use pre-commit
1 parent 67a12bb commit a8b9faf

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

.github/workflows/github-ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
jobs:
66

7-
style:
7+
pre-commit:
88

99
runs-on: ubuntu-latest
1010

@@ -20,14 +20,18 @@ jobs:
2020
- name: Upgrade pip
2121
run: python -m pip install --upgrade pip
2222

23-
- name: Install dependencies
24-
run: python -m pip install "flake8==4.0.1" "black==22.3.0"
23+
- name: Install pre-commit
24+
run: pip install pre-commit
2525

26-
- name: check style with black
27-
run: python -m black mip --line-length=89 --check --diff
26+
- name: Check pre-commit version
27+
run: pre-commit --version
28+
29+
- name: Set up hooks
30+
run: pre-commit install
31+
32+
- name: Check style
33+
run: pre-commit run --all-files
2834

29-
- name: check for unused imports with flake8
30-
run: python -m flake8 mip --select=F401 --exclude=__init__.py
3135

3236

3337
test:

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
files: ^mip/
2+
exclude: ^mip/_version.py
3+
repos:
4+
- repo: https://github.com/psf/black
5+
rev: 22.3.0
6+
hooks:
7+
- id: black
8+
args: [--line-length=89]
9+
- repo: https://gitlab.com/pycqa/flake8
10+
rev: 4.0.1
11+
hooks:
12+
- id: flake8
13+
args: [--select=F401, --exclude=__init__.py]

0 commit comments

Comments
 (0)