Skip to content

Commit

Permalink
Replace black with ruff format in project
Browse files Browse the repository at this point in the history
  • Loading branch information
niccolomineo committed Jan 4, 2024
1 parent 4cbe506 commit 8c95a08
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
5 changes: 1 addition & 4 deletions {{cookiecutter.project_dirname}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ repos:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.13.0"
hooks:
- id: django-upgrade
args: [--target-version, "4.1"]
- repo: https://github.com/psf/black
rev: "23.3.0"
hooks:
- id: black
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.9.2"
hooks:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_dirname}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dumpgroups: ## Django dump auth.Group data

.PHONY: fix
fix: ## Fix code formatting, linting and sorting imports
python3 -m black .
python3 -m ruff format .
python3 -m ruff --fix .
python3 -m mypy --no-site-packages .

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_dirname}}/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{ cookiecutter.project_name }}

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/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)

A [Django](https://docs.djangoproject.com) project using [uvicorn](https://www.uvicorn.org/#running-with-gunicorn) ASGI server.

Expand Down
10 changes: 6 additions & 4 deletions {{cookiecutter.project_dirname}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[tool.black]
target-version = ["py311"]

[tool.pytest.ini_options]
DJANGO_CONFIGURATION = "Testing"
DJANGO_SETTINGS_MODULE = "{{ cookiecutter.django_settings_dirname }}.settings"
Expand Down Expand Up @@ -66,7 +63,12 @@ select = ["A", "B", "C", "D", "E", "F", "I", "W", "B9"]
target-version = "py311"

[tool.ruff.per-file-ignores]
"{{ cookiecutter.django_settings_dirname }}/*sgi.py" = ["E402"]
"{{ cookiecutter.django_settings_dirname }}/*sgi.py" = [
"E402",
]

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.isort]
known-first-party = [
Expand Down
1 change: 0 additions & 1 deletion {{cookiecutter.project_dirname}}/requirements/test.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-r common.in
bandit[toml]~=1.7.0
behave-django~=1.4.0
black~=23.3.0
coverage[toml]~=7.2.0
mypy~=1.2.0
pactman~=2.30.0
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_dirname}}/scripts/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

python3 -m manage check
python3 -m manage makemigrations --dry-run --check
python3 -m black --check .
python3 -m ruff format --check .
python3 -m ruff check .
python3 -m mypy --no-site-packages .
python3 -m bandit --configfile pyproject.toml --quiet --recursive .
Expand Down

0 comments on commit 8c95a08

Please sign in to comment.