Skip to content

Commit

Permalink
Upgrade linting tools and switch to using ruff for linting and format…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
zerolab committed Apr 15, 2024
1 parent f17f16c commit bc3f81c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 53 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Ruff

on:
push:
branches:
- main
- 'stable/**'
pull_request:
branches: [main]

jobs:
ruff:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: python -Im pip install --user ruff

- name: Run ruff
run: ruff --output-format=github wagtail_footnotes
23 changes: 5 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -17,27 +17,14 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.280'
rev: 'v0.3.7'
hooks:
- id: ruff
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.15.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
- repo: https://github.com/adamchainz/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.7.0
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.12
rev: v0.9.18
hooks:
- id: pymarkdown
args:
Expand Down
36 changes: 2 additions & 34 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ dependencies = [
testing = [
"pre-commit>=3.3.0,<4",
"tox>=4.6.4,<5",
"black==23.7.0",
"ruff==0.0.280",
"ruff==0.3.7",
"coverage[toml]>=7.2,<8.0",
]

Expand All @@ -71,41 +70,10 @@ exclude = [
"*.ini",
"*.yml",
"CHANGELOG.md",
"ruff.toml",
"testmanage.py",
]

[tool.black]
line_length = 88
target-version = ["py38"]


[tool.ruff]
target-version = "py38"

extend-select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"PGH", # pygrep-hooks
"S", # flake8-bandit
"SIM", # flake8-simplify
"W", # pycodestyle warnings
"YTT", # flake8-2020
"UP", # pyupgrade
"RUF100", # unused noqa
]

# Never enforce `E501` (line length violations).
ignore = ["E501"]

[tool.ruff.isort]
known-first-party = ["src"]
lines-between-types = 1
lines-after-imports = 2


[tool.coverage.run]
branch = true
Expand Down
32 changes: 32 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[lint]
extend-select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
"E", # pycodestyle errors
"F", # pyflakes
"FBT", # flake8-boolean-trap
"I", # isort
"INT", # flake8-gettext
"PIE", # flake8-pie
"PGH", # pygrep-hooks
"S", # flake8-bandit
"SIM", # flake8-simplify
"W", # pycodestyle warnings
"YTT", # flake8-2020
"UP", # pyupgrade
"RUF100", # unused noqa
]

extend-ignore = [
"E501", # no line length errors
]
fixable = ["C4", "E", "F", "I", "UP"]

[lint.isort]
known-first-party = ["wagtail_footnotes"]
lines-between-types = 1
lines-after-imports = 2

[format]
docstring-code-format = true
4 changes: 3 additions & 1 deletion tests/test/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def setUp(self):
)

self.admin_user = User.objects.create_superuser(
username="admin", email="", password="password" # noqa: S106
username="admin",
email="",
password="password", # noqa: S106
)

def test_no_footnote(self):
Expand Down

0 comments on commit bc3f81c

Please sign in to comment.