Skip to content

Commit 8fcc1a3

Browse files
authored
use precommit for code linting (#829)
* use precommit * make * packages
1 parent f09be0a commit 8fcc1a3

File tree

5 files changed

+19
-37
lines changed

5 files changed

+19
-37
lines changed

.github/workflows/tests.yml

-23
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,9 @@ on:
1111
branches: [ master ]
1212

1313
jobs:
14-
15-
lint:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v2
21-
with:
22-
python-version: 3.7
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
27-
make install_dev
28-
- name: Run Flake8
29-
run: make flake8
30-
- name: Run Black
31-
run: make black
3214

3315
test:
3416
runs-on: ubuntu-latest
35-
needs: [lint]
3617
steps:
3718
- uses: actions/checkout@v2
3819
- name: Set up Python ${{ matrix.python-version }}
@@ -44,7 +25,3 @@ jobs:
4425
python -m pip install --upgrade pip
4526
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
4627
make install_dev
47-
- name: Run Flake8
48-
run: make flake8
49-
- name: Run Tests
50-
run: make test

.pre-commit-config.yaml

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
default_language_version:
2+
python: python3
3+
4+
ci:
5+
autofix_prs: true
6+
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
7+
autoupdate_schedule: quarterly
8+
# submodules: true
9+
110
repos:
211
- repo: https://github.com/psf/black
312
rev: 22.3.0
413
hooks:
514
- id: black
6-
args: [ --config=pyproject.toml ]
15+
args: ["--config=pyproject.toml"]
16+
717
- repo: https://github.com/pycqa/flake8.git
818
rev: 4.0.1
919
hooks:
1020
- id: flake8
11-
args: [ --config=.flake8 ]
12-
additional_dependencies: [ flake8-docstrings==1.6.0 ]
21+
args: ["--config=.flake8"]
22+
additional_dependencies:
23+
- "flake8-docstrings==1.6.0"

Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ table:
1616
table_timm:
1717
.venv/bin/python misc/generate_table_timm.py
1818

19-
black: .venv
20-
.venv/bin/black ./segmentation_models_pytorch --config=pyproject.toml --check
19+
precommit: install_dev
20+
.venv/bin/pre-commit run --all-files
2121

22-
flake8: .venv
23-
.venv/bin/flake8 ./segmentation_models_pytorch --config=.flake8
24-
25-
all: black flake8 test
22+
all: precommit test

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,10 @@ $ pip install git+https://github.com/qubvel/segmentation_models.pytorch
475475
make install_dev # create .venv, install SMP in dev mode
476476
```
477477

478-
#### Run tests and code checks
478+
#### Run tests and code checks
479479

480480
```bash
481-
make all # run flake8, black, tests
481+
make all # run precommit, tests
482482
```
483483

484484
#### Update table with encoders

setup.py

-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
"pytest",
4141
"mock",
4242
"pre-commit",
43-
"black==22.3.0",
44-
"flake8==4.0.1",
45-
"flake8-docstrings==1.6.0",
4643
],
4744
}
4845

0 commit comments

Comments
 (0)