Skip to content

Commit ed7f912

Browse files
committed
Align linting config with Black
1 parent 2841794 commit ed7f912

5 files changed

Lines changed: 41 additions & 20 deletions

File tree

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
max-line-length = 88
3+
exclude = .tox,.git,*/migrations/*,venv,dist,build,*.pyc,*.egg-info
4+
ignore = E203,E231,E266,E501,W503,B950,F405
5+
max-complexity = 11

.github/workflows/test.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ on:
88
workflow_call: # Allow for the publish workflows to run the tests by calling this workflow
99

1010
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: 3.13
21+
cache: 'pip'
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install .[test]
25+
- name: Run linting
26+
run: |
27+
make format
1128
test:
1229
name: Python ${{ matrix.python}} ${{ matrix.toxenv }}
1330
runs-on: ubuntu-latest
@@ -18,13 +35,6 @@ jobs:
1835
experimental: [false]
1936
toxenv: ["py"]
2037
include:
21-
# Linting
22-
- python: "3.13"
23-
toxenv: flake8
24-
experimental: false
25-
- python: "3.13"
26-
toxenv: isort
27-
experimental: false
2838
# Future Wagtail release from main branch (allowed to fail)
2939
- python: "3.13"
3040
toxenv: wagtailmain

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313
- Compatibility with Django 5.2 and 6.0.
1414
- Compatibility with Wagtail 7.0, 7.3 LTS, and 7.4.
1515
- Switch `setup.py` to `pyproject.toml`.
16+
- Linting with `black`, `isort` and `flake8`.
1617
- Added back coverage reporting.
1718

1819
### Fixed

Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
.PHONY: help all clean install flake8 isort lint test
1+
.PHONY: help all clean install format test
22
.DEFAULT_GOAL := help
33

44
help: ## See what commands are available.
55
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36mmake %-15s\033[0m # %s\n", $$1, $$2}'
66

77

8-
all: install clean test lint ## Install, test and lint the project.
8+
all: clean install format test ## Install, format and test the project.
99

1010
clean: ## Remove Python file artifacts.
1111
find . -name '*.pyc' -exec rm -rf {} +
@@ -16,16 +16,13 @@ clean: ## Remove Python file artifacts.
1616
install: ## Install dependencies.
1717
pip install -e .[test]
1818

19-
flake8: ## Run flake8 on the project.
20-
flake8 src/ tests/
21-
22-
isort: ## Run isort on the project.
23-
isort --check-only --diff src/ tests/
24-
25-
lint: flake8 isort ## Lint the project.
19+
format: ## Format the code.
20+
black .
21+
isort .
22+
flake8 .
2623

2724
test: ## Test the project.
2825
pytest --cov
2926

30-
cov: ## Generate coverage report (manually open htmlcov/index.html in browser)
27+
cov: ## Generate coverage report (manually open htmlcov/index.html in browser)
3128
pytest --cov --cov-report html

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ dependencies = [
3636

3737
[project.optional-dependencies]
3838
test = [
39+
"black>=26,<27",
3940
"coverage[toml]>=7.13.5,<8.0",
4041
"factory-boy",
4142
"flake8",
43+
"flake8-black",
44+
"flake8-isort",
4245
"isort",
4346
"pytest-cov",
4447
"pytest-django",
@@ -61,9 +64,14 @@ where = ["src"]
6164
testpaths = ["tests"]
6265

6366
[tool.isort]
64-
line_length = 100
65-
multi_line_output = 4
66-
known_third_party = ["bakery", "django", "factory", "pytest", "wagtail"]
67+
force_grid_wrap = 0
68+
include_trailing_comma = true
69+
line_length = 88
70+
multi_line_output = 3
71+
use_parentheses = true
72+
73+
[tool.black]
74+
line-length = 88
6775

6876
[tool.coverage.run]
6977
branch = true

0 commit comments

Comments
 (0)