Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use precommit for code linting #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,9 @@ on:
branches: [ master ]

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
make install_dev
- name: Run Flake8
run: make flake8
- name: Run Black
run: make black

test:
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -44,7 +25,3 @@ jobs:
python -m pip install --upgrade pip
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
make install_dev
- name: Run Flake8
run: make flake8
- name: Run Tests
run: make test
17 changes: 14 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
autoupdate_schedule: quarterly
# submodules: true

repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [ --config=pyproject.toml ]
args: ["--config=pyproject.toml"]

- repo: https://github.com/pycqa/flake8.git
rev: 4.0.1
hooks:
- id: flake8
args: [ --config=.flake8 ]
additional_dependencies: [ flake8-docstrings==1.6.0 ]
args: ["--config=.flake8"]
additional_dependencies:
- "flake8-docstrings==1.6.0"
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ table:
table_timm:
.venv/bin/python misc/generate_table_timm.py

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

flake8: .venv
.venv/bin/flake8 ./segmentation_models_pytorch --config=.flake8

all: black flake8 test
all: precommit test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,10 @@ $ pip install git+https://github.com/qubvel/segmentation_models.pytorch
make install_dev # create .venv, install SMP in dev mode
```

#### Run tests and code checks
#### Run tests and code checks

```bash
make all # run flake8, black, tests
make all # run precommit, tests
```

#### Update table with encoders
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
"pytest",
"mock",
"pre-commit",
"black==22.3.0",
"flake8==4.0.1",
"flake8-docstrings==1.6.0",
],
}

Expand Down