Skip to content

Commit

Permalink
chore: replace Black, Flake8 and isort with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas777 committed Oct 31, 2024
1 parent c1f7909 commit f9ff61b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 87 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,16 @@ jobs:
run: |
python manage.py spectacular --lang en --validate --fail-on-warn --api-version v1
- name: Check black
run: |
black --check .
- name: Check flake8
uses: liskin/gh-problem-matcher-wrap@v2
- name: Run Ruff lint
uses: astral-sh/ruff-action@v1
with:
linters: flake8
run: flake8
version: 0.7.1

- name: Check isort
uses: liskin/gh-problem-matcher-wrap@v2
- name: Run Ruff format check
uses: astral-sh/ruff-action@v1
with:
linters: isort
run: isort . --check-only --diff
version: 0.7.1
args: "format --check"

- name: Check commitlint
uses: wagoid/commitlint-github-action@0d749a1a91d4770e983a7b8f83d4a3f0e7e0874e # v5.4.4
Expand Down
21 changes: 7 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@ repos:
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [pep8-naming, flake8-bugbear]
exclude: "migrations|tests"
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
exclude: "migrations"
- id: ruff
name: ruff lint
- id: ruff-format
name: ruff format
args: [ --check ]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.18.0
hooks:
Expand Down
34 changes: 25 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
[tool.black]
line-length = 88 # Black's default value
target-version = ["py39"]
[tool.ruff]
target-version = "py39"

[tool.isort]
profile = "black"
py_version = 39
atomic = true
order_by_type = false
extend_skip_glob = ["*migrations*"]
[tool.ruff.lint]
select = [
# Pyflakes
"F",
# pycodestyle
"E",
"W",
# isort
"I",
# pep8-naming
"N",
# flake8-bugbear without opinionated rules
"B0",
# flake8-pie
"PIE",
# flake8-print
"T20",
]
extend-per-file-ignores = { "*/migrations/*" = ["E501"], "*/tests/*" = ["E501"] }

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "linkedevents.test_settings"
norecursedirs = [".git", "venv"]
7 changes: 2 additions & 5 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
-c requirements.txt

Werkzeug
black
django-anymail
django-debug-toolbar
django-extensions
factory_boy
flake8
flake8-bugbear
freezegun
isort
pep8-naming
pip-tools
pytest
pytest-cov
Expand All @@ -19,4 +14,6 @@ pytest-factoryboy
pytest-freezer
python-jose
requests-mock
# Keep this in sync with .pre-commit-config.yaml
ruff==0.7.1
snakemd
42 changes: 4 additions & 38 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ asgiref==3.8.1
# via
# -c requirements.txt
# django
attrs==24.2.0
# via
# -c requirements.txt
# flake8-bugbear
black==24.8.0
# via -r requirements-dev.in
build==1.2.2
# via pip-tools
certifi==2024.8.30
Expand All @@ -25,9 +19,7 @@ charset-normalizer==3.3.2
# -c requirements.txt
# requests
click==8.1.7
# via
# black
# pip-tools
# via pip-tools
coverage[toml]==7.6.1
# via pytest-cov
django==4.2.16
Expand Down Expand Up @@ -56,13 +48,6 @@ factory-boy==3.3.1
# pytest-factoryboy
faker==29.0.0
# via factory-boy
flake8==7.1.1
# via
# -r requirements-dev.in
# flake8-bugbear
# pep8-naming
flake8-bugbear==24.8.19
# via -r requirements-dev.in
freezegun==1.5.1
# via
# -r requirements-dev.in
Expand All @@ -81,44 +66,25 @@ inflection==0.5.1
# pytest-factoryboy
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via -r requirements-dev.in
markupsafe==2.1.5
# via
# -c requirements.txt
# werkzeug
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
# via black
packaging==24.1
# via
# -c requirements.txt
# black
# build
# pytest
# pytest-factoryboy
pathspec==0.12.1
# via black
pep8-naming==0.14.1
# via -r requirements-dev.in
pip-tools==7.4.1
# via -r requirements-dev.in
platformdirs==4.3.6
# via
# -c requirements.txt
# black
pluggy==1.5.0
# via pytest
pyasn1==0.6.1
# via
# -c requirements.txt
# python-jose
# rsa
pycodestyle==2.12.1
# via flake8
pyflakes==3.2.0
# via flake8
pyproject-hooks==1.1.0
# via
# build
Expand Down Expand Up @@ -158,6 +124,8 @@ rsa==4.9
# via
# -c requirements.txt
# python-jose
ruff==0.7.1
# via -r requirements-dev.in
six==1.16.0
# via
# -c requirements.txt
Expand All @@ -170,9 +138,8 @@ sqlparse==0.5.1
# -c requirements.txt
# django
# django-debug-toolbar
tomli==2.0.1
tomli==2.0.2
# via
# black
# build
# coverage
# pip-tools
Expand All @@ -181,7 +148,6 @@ typing-extensions==4.12.2
# via
# -c requirements.txt
# asgiref
# black
# pytest-factoryboy
urllib3==1.26.20
# via
Expand Down
9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.

0 comments on commit f9ff61b

Please sign in to comment.