Skip to content

Commit f881193

Browse files
committed
Add pre-commit CI
1 parent 9bebc8a commit f881193

35 files changed

+232
-230
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
name: CI
2-
32
on:
43
push:
54
branches:
65
- main
76
pull_request:
8-
97
jobs:
10-
11-
lint:
12-
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
lint-command:
16-
- bandit -r . -x ./tests
17-
- black --check --diff .
18-
- flake8 .
19-
- isort --check-only --diff .
20-
- pydocstyle .
21-
steps:
22-
- uses: actions/checkout@v5
23-
- uses: actions/setup-python@v6
24-
with:
25-
python-version: "3.x"
26-
cache: 'pip'
27-
cache-dependency-path: pyproject.toml
28-
- run: python -m pip install .[lint]
29-
- run: ${{ matrix.lint-command }}
30-
318
docs:
329
runs-on: ubuntu-latest
3310
steps:
@@ -39,7 +16,6 @@ jobs:
3916
- run: python -m pip install sphinxcontrib-spelling
4017
- run: python -m pip install -e '.[docs]'
4118
- run: python -m sphinx -W -b spelling docs docs/_build
42-
4319
dist:
4420
runs-on: ubuntu-latest
4521
steps:
@@ -50,11 +26,9 @@ jobs:
5026
- run: python -m pip install --upgrade pip build wheel twine readme-renderer
5127
- run: python -m build --sdist --wheel
5228
- run: python -m twine check dist/*
53-
5429
PyTest:
5530
needs:
5631
- dist
57-
- lint
5832
runs-on: ubuntu-latest
5933
strategy:
6034
matrix:

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
name: Release
2-
32
on:
43
release:
54
types: [published]
6-
75
jobs:
8-
96
PyPi:
107
runs-on: ubuntu-latest
118
steps:

.pre-commit-config.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: check-merge-conflict
9+
- id: check-ast
10+
- id: check-toml
11+
- id: check-yaml
12+
- id: debug-statements
13+
- id: end-of-file-fixer
14+
- id: name-tests-test
15+
args: ['--pytest-test-first']
16+
exclude: ^tests/(testapp/|manage.py$)
17+
- id: no-commit-to-branch
18+
args: [--branch, main]
19+
- repo: https://github.com/asottile/pyupgrade
20+
rev: v3.21.1
21+
hooks:
22+
- id: pyupgrade
23+
- repo: https://github.com/adamchainz/django-upgrade
24+
rev: 1.29.1
25+
hooks:
26+
- id: django-upgrade
27+
- repo: https://github.com/hukkin/mdformat
28+
rev: 1.0.0
29+
hooks:
30+
- id: mdformat
31+
additional_dependencies:
32+
- mdformat-ruff
33+
- mdformat-footnote
34+
- mdformat-gfm
35+
- mdformat-gfm-alerts
36+
- repo: https://github.com/astral-sh/ruff-pre-commit
37+
rev: v0.14.4
38+
hooks:
39+
- id: ruff-check
40+
args: [--fix, --exit-non-zero-on-fix]
41+
- id: ruff-format
42+
- repo: https://github.com/google/yamlfmt
43+
rev: v0.20.0
44+
hooks:
45+
- id: yamlfmt
46+
- repo: https://github.com/djlint/djLint
47+
rev: v1.36.4
48+
hooks:
49+
- id: djlint-reformat-django
50+
ci:
51+
autoupdate_schedule: weekly
52+
skip:
53+
- no-commit-to-branch

.readthedocs.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# .readthedocs.yaml
22
# Read the Docs configuration file
33
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4-
54
version: 2
6-
75
build:
86
os: ubuntu-20.04
97
tools:
108
python: "3.11"
119
apt_packages:
1210
- graphviz
13-
1411
sphinx:
1512
configuration: docs/conf.py
16-
1713
python:
1814
install:
1915
- method: pip

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ to add code to their runtime environment that they don't need.
2727
All features need to be tested. A CI suite should be in place. Running and
2828
writing tests should be reasonably accessible for first time contributors.
2929

30-
3130
## Release
3231

3332
We follow [semantic versioning](https://semver.org/). To release a new version

docs/conf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def linkcode_resolve(domain, info):
4949
pass
5050
try:
5151
lines, first_line = inspect.getsourcelines(item)
52-
lineno = "#L%d-L%s" % (first_line, first_line + len(lines) - 1)
52+
lineno = f"#L{first_line:d}-L{first_line + len(lines) - 1:d}"
5353
except (TypeError, OSError):
5454
pass
5555
return (
@@ -79,6 +79,9 @@ def linkcode_resolve(domain, info):
7979

8080
graphviz_output_format = "svg"
8181

82-
inheritance_graph_attrs = dict(
83-
rankdir="TB", size='"6.0, 8.0"', fontsize=14, ratio="compress"
84-
)
82+
inheritance_graph_attrs = {
83+
"rankdir": "TB",
84+
"size": '"6.0, 8.0"',
85+
"fontsize": 14,
86+
"ratio": "compress",
87+
}

docs/tutorial/testing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ running workflow. You can test any other task by simply creating the
9090
workflow and task in during test setup. In those cases you will need
9191
pass the task primary key. You can find more information about this
9292
in the :ref:`URLs documentation<topic-urls>`.
93-

joeflow/admin.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.contrib import admin, messages
22
from django.contrib.auth import get_permission_codename
33
from django.db import transaction
4-
from django.forms.widgets import MediaAsset, Media, Script
4+
from django.forms.widgets import Media, MediaAsset, Script
55
from django.utils.html import format_html
66
from django.utils.safestring import mark_safe
77
from django.utils.translation import gettext_lazy as t
@@ -21,13 +21,13 @@ def rerun(modeladmin, request, queryset):
2121
if succeeded:
2222
messages.warning(
2323
request,
24-
"Only failed tasks can be retried. %s tasks have been skipped" % succeeded,
24+
f"Only failed tasks can be retried. {succeeded} tasks have been skipped",
2525
)
2626
counter = 0
2727
for obj in queryset.not_succeeded().iterator():
2828
obj.enqueue()
2929
counter += 1
30-
messages.success(request, "%s tasks have been successfully queued" % counter)
30+
messages.success(request, f"{counter} tasks have been successfully queued")
3131

3232

3333
@admin.action(
@@ -39,8 +39,7 @@ def cancel(modeladmin, request, queryset):
3939
if not_scheduled:
4040
messages.warning(
4141
request,
42-
"Only scheduled tasks can be canceled. %s tasks have been skipped"
43-
% not_scheduled,
42+
f"Only scheduled tasks can be canceled. {not_scheduled} tasks have been skipped",
4443
)
4544
queryset.scheduled().cancel(request.user)
4645
messages.success(request, "Tasks have been successfully canceled")
@@ -138,12 +137,11 @@ class TaskInlineAdmin(admin.TabularInline):
138137

139138

140139
class CSS(MediaAsset):
141-
142140
element_template = "<style{attributes}>{path}</style>"
143141

144142
@property
145143
def path(self):
146-
return mark_safe(self._path)
144+
return mark_safe(self._path) # noqa: S308
147145

148146

149147
class WorkflowAdmin(VersionAdmin):
@@ -168,7 +166,7 @@ def get_readonly_fields(self, *args, **kwargs):
168166
def display_workflow_diagram(self, obj):
169167
"""Display workflow diagram using MermaidJS for client-side rendering."""
170168
if obj.pk:
171-
return mark_safe(
169+
return mark_safe( # noqa: S308
172170
f"""<pre class="mermaid" style="width: 100%; display: block">{obj.get_instance_graph_mermaid()}</pre>"""
173171
)
174172
return ""

joeflow/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66

77
class JoeflowAppConfig(AppConf):
8-
"""
9-
List of available settings.
8+
"""List of available settings.
109
1110
To change the default values just set the setting in your settings file.
1211
"""

joeflow/management/commands/render_workflow_graph.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def handle(self, *args, **options):
5353
opt = workflow._meta
5454
if verbosity > 0:
5555
self.stdout.write(
56-
"Rendering graph for '%s.%s'… "
57-
% (opt.app_label, opt.model_name),
56+
f"Rendering graph for '{opt.app_label}.{opt.model_name}'… ",
5857
ending="",
5958
)
6059
filename = f"{opt.app_label}_{workflow.__name__}".lower()
@@ -65,5 +64,5 @@ def handle(self, *args, **options):
6564
self.stdout.write("Done!", self.style.SUCCESS)
6665
else:
6766
self.stderr.write(
68-
"%r is not a Workflow subclass" % workflow, self.style.WARNING
67+
f"{workflow!r} is not a Workflow subclass", self.style.WARNING
6968
)

0 commit comments

Comments
 (0)