Skip to content

Commit fbb0bfa

Browse files
committed
Add ruff as the tool for linting and formatting files
1 parent 3de87a4 commit fbb0bfa

File tree

14 files changed

+66
-72
lines changed

14 files changed

+66
-72
lines changed

.flake8

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
run: invoke requirements-dev
3939

4040
- name: Run tests
41-
run: invoke test
41+
run: invoke test-new

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ repos:
1414
hooks:
1515
- id: validate-pyproject
1616

17-
- repo: https://github.com/PyCQA/flake8
18-
rev: 7.0.0
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
# Ruff version.
19+
rev: v0.14.13
1920
hooks:
20-
- id: flake8
21+
# Run the linter.
22+
- id: ruff-check
23+
args: [ --fix ]
24+
# Run the formatter.
25+
- id: ruff-format

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
### Added
1010

11-
- [GOV.UK Frontend v5.13.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.12.0) support
11+
- [GOV.UK Frontend v5.13.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.14.0) support
1212
- Add support for Python 3.14 (πthon)
13+
- [GOV.UK Frontend v5.14.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.14.0) support
1314

1415
## [1.7.0](https://github.com/Crown-Commercial-Service/ccs-govuk-frontend-jinja/releases/tag/1.7.0) - 30/06/2025
1516

govuk_frontend_jinja/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.7.0"
1+
__version__ = '1.7.0'

govuk_frontend_jinja/templates/components/character-count/macro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
'formGroup': {
105105
'classes': 'govuk-character-count' ~ (' ' ~ params.formGroup.classes if params.formGroup and params.formGroup.classes),
106106
'attributes': attributesHtml,
107-
'beforeInput': params.formGroup.beforeInput if params.fromGroup,
107+
'beforeInput': params.formGroup.beforeInput if params.formGroup,
108108
'afterInput': {
109109
'html': countMessageHtml
110110
}

govuk_frontend_jinja/templates/components/footer/macro.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ <h2 class="govuk-visually-hidden">{{ params.meta.visuallyHiddenTitle | default("
6161
</div>
6262
{% endif %}
6363
{% endif %}
64+
{% if params.contentLicence is not none %}
6465
{# The SVG needs `focusable="false"` so that Internet Explorer does not
6566
treat it as an interactive element - without this it will be
6667
'focusable' when using the keyboard to navigate. -#}
@@ -90,6 +91,7 @@ <h2 class="govuk-visually-hidden">{{ params.meta.visuallyHiddenTitle | default("
9091
>Open Government Licence v3.0</a>, except where otherwise stated
9192
{% endif %}
9293
</span>
94+
{% endif %}
9395
</div>
9496
<div class="govuk-footer__meta-item">
9597
<a

govuk_frontend_jinja/templates/components/pagination/macro.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@
6969
{%- if 'items' in params %}
7070
<ul class="govuk-pagination__list">
7171
{% for item in params['items'] %}
72-
{{ _pageItem(item) | indent(2) }}
72+
{% if item is not none and (item | length) > 0 %}
73+
{{ _pageItem(item) | indent(2) }}
74+
{% endif %}
7375
{% endfor %}
7476
</ul>
7577
{% endif %}

govuk_frontend_jinja/templates/components/service-navigation/macro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{% if navigationItems | length or params.slots and (params.slots.navigationStart or params.slots.navigationEnd) %}
3939
<nav aria-label="{{ params.navigationLabel | default(menuButtonText, true) }}" class="govuk-service-navigation__wrapper {%- if params.navigationClasses %} {{ params.navigationClasses }}{% endif %}">
4040
{% if collapseNavigationOnMobile %}
41-
<button type="button" class="govuk-service-navigation__toggle govuk-js-service-navigation-toggle" aria-controls="{{ navigationId }}" {%- if params.menuButtonLabel and params.menuButtonLabel != menuButtonText %} aria-label="{{ params.menuButtonLabel }}"{% endif %} hidden>
41+
<button type="button" class="govuk-service-navigation__toggle govuk-js-service-navigation-toggle" aria-controls="{{ navigationId }}" {%- if params.menuButtonLabel and params.menuButtonLabel != menuButtonText %} aria-label="{{ params.menuButtonLabel }}"{% endif %} hidden aria-hidden="true">
4242
{{ menuButtonText }}
4343
</button>
4444
{% endif %}

pyproject.toml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Changelog = "https://github.com/Crown-Commercial-Service/ccs-govuk-frontend-jinj
2525

2626
[project.optional-dependencies]
2727
dev = [
28-
'flake8==7.3.0',
28+
'ruff==0.14.13',
2929
'mypy==1.19.1',
3030
'pytest==9.0.2',
3131
'lxml==6.0.2',
@@ -46,3 +46,23 @@ govuk_frontend_jinja = ["**/*.html"]
4646
[tool.pytest.ini_options]
4747
addopts = "-p no:logging"
4848
testpaths = "tests"
49+
50+
[tool.ruff]
51+
line-length = 120
52+
53+
target-version = "py311"
54+
55+
[tool.ruff.format]
56+
quote-style = "single"
57+
58+
indent-style = "space"
59+
60+
skip-magic-trailing-comma = false
61+
62+
line-ending = "auto"
63+
64+
[tool.ruff.lint.mccabe]
65+
max-complexity = 12
66+
67+
[tool.ruff.lint.per-file-ignores]
68+
"app/__init__.py" = ["E501"]

0 commit comments

Comments
 (0)