Skip to content

Commit

Permalink
Replace black for formatting with ruff
Browse files Browse the repository at this point in the history
* Add workflow to check formatting using ruff
* Add ruff formatting to pre-commit
* Remove black
  • Loading branch information
johannaengland authored Oct 17, 2024
1 parent 91c21b1 commit a531c0b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Format codebase

on:
push:
branches: master
pull_request:

jobs:
format:
runs-on: ubuntu-latest
name: Format
steps:
- uses: actions/checkout@v4

- name: Format
uses: astral-sh/ruff-action@v1
with:
args: "format --check"
# changed-files: 'true'
8 changes: 3 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
# Run the linter
- id: ruff
name: "Ruff: critical"
args: [
Expand All @@ -18,11 +19,8 @@ repos:
'--statistics'
]
types: [file, python]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
exclude: migrations/
# Run the formatter
- id: ruff-format
- repo: https://github.com/twisted/towncrier
rev: 24.8.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Argus
[![build badge](https://github.com/Uninett/Argus/workflows/build/badge.svg)](https://github.com/Uninett/Argus/actions)
[![codecov badge](https://codecov.io/gh/Uninett/Argus/branch/master/graph/badge.svg)](https://codecov.io/gh/Uninett/Argus)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![docs badge](https://readthedocs.org/projects/argus-server/badge/?version=latest&style=flat)](http://argus-server.rtfd.io/en/latest/)

Argus is a platform for aggregating incidents across network management systems, and
Expand Down Expand Up @@ -199,7 +199,7 @@ You will find Argus running at http://localhost:8000/.

### Code style

Argus uses black as a source code formatter. Black will automatically install
Argus uses ruff as a source code formatter. Ruff will automatically install
with the [dev requirements](requirements/dev.txt).

A pre-commit hook will format new code automatically before committing.
Expand Down
22 changes: 0 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ dynamic = ["version"]
docs = ["sphinx>=2.2.0"]
dev = [
"django-debug-toolbar",
"black",
"coverage",
"django-extensions",
"ruff",
Expand Down Expand Up @@ -86,27 +85,6 @@ exclude = ["tests*"]
[tool.setuptools_scm]
write_to = "src/argus/version.py"

[tool.black]
line-length = 120
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.nox
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| src/.*/migrations
)
'''

[tool.ruff]
line-length = 120
extend-exclude = [
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Sphinx>=2.2.0
python-dotenv
black
ruff
pre-commit
ipython
django-extensions
Expand Down

0 comments on commit a531c0b

Please sign in to comment.