Skip to content

Commit

Permalink
style/ci(linter/formatter): use ruff & black only
Browse files Browse the repository at this point in the history
Only use ruff and black to lint and format code.
Only run linter and formatter in CI.
Do not bother with test setup.
  • Loading branch information
matthiasschaub committed Oct 10, 2023
1 parent e00a309 commit b10be00
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 277 deletions.
45 changes: 6 additions & 39 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
name: Python Tools and Tests

on: [ push ]

name: Python Linting
on: [ push, pull_request ]
jobs:
build-analyze-test:
runs-on: ubuntu-22.04
name: "Build, Analyze and Test"
defaults:
run:
shell: bash
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: awalsh128/cache-apt-pkgs-action@v1
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- name: Install system dependencies
run: sudo apt-get install -y --no-upgrade libzbar0 libgdal-dev libgl1
- name: Install numpy
run: poetry run pip install numpy==1.23.5
- name: Install pygdal
run: poetry run pip install pygdal==3.4.1.10
- name: Install dependencies
run: poetry install
- name: Run flake8
run: poetry run flake8 sketch_map_tool
continue-on-error: true
- name: Run bandit
run: poetry run bandit --recursive sketch_map_tool
continue-on-error: true
- name: Run black
run: poetry run black --check --diff sketch_map_tool
continue-on-error: true
- name: Run isort
run: poetry run isort --check --diff sketch_map_tool
continue-on-error: true
- name: Running tests
run: poetry run pytest tests/unit
- uses: chartboost/ruff-action@v1
- uses: psf/black@stable
24 changes: 3 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,10 @@ repos:
hooks:
- id: black
args: ["--check", "--diff"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: isort
args: ["--check", "--diff"]
- repo: https://github.com/pycqa/flake8
rev: "5.0.4"
hooks:
- id: flake8
args: ["--count", "--statistics"]
- repo: https://github.com/pycqa/bandit
rev: "1.7.4"
hooks:
- id: bandit
name: bandit
exclude: tests
# TODO: mypy ignores config
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: "v0.981"
# hooks:
# - id: mypy
# args: ["--config-file", "setup.cfg"]
- id: ruff
# Javascript
- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v8.24.0"
Expand Down
15 changes: 5 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,17 @@ In short:
- Guideline: [PEP8](https://peps.python.org/pep-0008/), [PEP 484 (Type Hints)](https://peps.python.org/pep-0484/)
- Linter: [flake8](https://flake8.pycqa.org), [mypy](http://mypy-lang.org/), [bandit](https://github.com/PyCQA/bandit)

#### Linters
#### Linters and Autoformatter

This project uses [flake8](https://flake8.pycqa.org), [mypy](http://mypy-lang.org/) and [bandit](https://github.com/PyCQA/bandit) to ensure consistent code style.
This project uses [`black`](https://github.com/psf/black) and [`ruff`](https://github.com/astral-sh/ruff) to ensure consistent code style. See the `pyproject.toml` file for configuration.

Run those linter's with following commands:
Run those linter's/autoformatter's with following commands:

```bash
flake8 .
mypy --strict .
bandit -r .
black .
ruff .
```

*Tips:*
- Mark in-line that flake8 should not raise any error: `print() # noqa`
- Mark in-line that bandit should not raise any error: `# nosec`

### JavaScript and CSS

In short:
Expand Down
Loading

0 comments on commit b10be00

Please sign in to comment.