Skip to content

Commit 4863158

Browse files
authored
Add code formatter and pre-commit (#12)
1 parent 0db2ed8 commit 4863158

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Ruff
2+
on: [ push, pull_request ]
3+
4+
jobs:
5+
ruff:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: chartboost/ruff-action@v1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.6.1
4+
hooks:
5+
- id: ruff
6+
- id: ruff-format

{{cookiecutter.name}}/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,35 @@ MAKE = make
77
PY = python3
88
RM = rm -rf
99
GIT = git
10+
OPEN = xdg-open
1011

1112
# Build sphinx documentation.
1213
.PHONY: docs
1314
docs:
1415
$(MAKE) -C docs/
1516

17+
# View sphinx HTML documentation in browser.
18+
.PHONY: view
19+
view:
20+
$(OPEN) docs/_build/html/index.html
21+
22+
.PHONY: clean
23+
clean:
24+
$(MAKE) -C docs/ clean
25+
$(RM) dist/
26+
27+
.PHONY: clean
28+
fmt:
29+
ruff format src/
30+
1631
# Run unittest.
1732
.PHONY: test
1833
test:
1934
$(PY) -m unittest discover -s tests -v
2035

2136
# Build distribution package, for "install" or "upload".
2237
.PHONY: dist
23-
dist: pyproject.toml
24-
$(RM) dist/ # clean up old dist
38+
dist: pyproject.toml clean
2539
$(PY) -m build
2640

2741
# Install distribution package to user directory.
@@ -61,3 +75,7 @@ update-template-done:
6175
bump-version:
6276
@echo -n "Please enter the version to bump: "
6377
@read version && $(PY) -m cruft update --variables-to-update "{ \"version\" : \"$$version\" }"
78+
79+
# EXTRA TARGETS START
80+
81+
# EXTRA TARGETS END

{{cookiecutter.name}}/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ dev = [
3838
"build",
3939
"twine",
4040
"cruft",
41+
"ruff",
42+
"pre-commit"
4143
]
4244
test = [
4345
"pytest",

{{cookiecutter.name}}/ruff.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[format]
2+
quote-style = "single"

0 commit comments

Comments
 (0)