Skip to content

Commit 35b0bf3

Browse files
committed
update template
1 parent a61b498 commit 35b0bf3

File tree

5 files changed

+72
-66
lines changed

5 files changed

+72
-66
lines changed

template/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ indent_size = 4
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
9+
end_of_line = lf
910

1011
[{*.yaml, *.yml}]
1112
indent_size = 2
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
name: Tests
22
on: [push, pull_request]
3+
34
jobs:
45
tests:
5-
runs-on: ubuntu-latest
66
strategy:
77
fail-fast: false
88
matrix:
9+
os: [ubuntu-latest, macos-latest, windows-latest]
910
python-version: [
1011
{%- for version in py_versions_range(python_min_version, python_max_version) %}
1112
"{{ version }}"{{ "," if not loop.last }}
1213
{%- endfor %}
1314
]
15+
runs-on: {% raw %}${{ matrix.os }}{% endraw %}
16+
1417
steps:
15-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
19+
1620
- name: Install uv
17-
uses: astral-sh/setup-uv@v3
21+
uses: astral-sh/setup-uv@v7
22+
1823
{% raw %}
1924
- name: Set up Python ${{ matrix.python-version }}
2025
run: uv python install ${{ matrix.python-version }}
26+
2127
- name: Install dependencies
2228
run: uv sync --extra test --python ${{ matrix.python-version }}
29+
2330
- name: Run pytest
2431
run: uv run --python ${{ matrix.python-version }} pytest -v
2532
{% endraw %}

template/.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ repos:
88
- id: check-toml
99

1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.8.4
11+
rev: v0.14.2
1212
hooks:
13-
- id: ruff
14-
args: [--fix, --exit-non-zero-on-fix]
13+
- id: ruff-check
14+
args: [--fix]
1515
- id: ruff-format

template/Justfile

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
11
@_:
2-
just --list
2+
just --list
33

44
_require-uv:
5-
@uv --version > /dev/null || (echo "Please install uv: https://docs.astral.sh/uv/" && exit 1)
5+
@uv --version > /dev/null || (echo "Please install uv: https://docs.astral.sh/uv/" && exit 1)
66

77
_require-hatch:
88
@hatch --version > /dev/null || (echo "Please install hatch: uv tool install hatch" && exit 1)
99

1010
# check code style and potential issues
1111
lint:
12-
ruff check
13-
14-
# fix automatically fixable linting issues
15-
fix:
16-
ruff check --fix
12+
ruff check
1713

1814
# format code
1915
format:
20-
ruff format
16+
ruff format
17+
18+
# fix automatically fixable linting issues
19+
fix:
20+
ruff check --fix
2121

2222
# run tests across all supported Python versions
2323
test: _require-hatch
24-
hatch run test:test
24+
hatch run -m test:test
2525

2626
# run all quality checks
2727
check: format lint test
2828

2929
# build the package
3030
build: _require-uv
31-
uv build
31+
uv build
3232

33-
# setup development environment
33+
# setup or update local dev environment, keeps previously installed extras
3434
dev: _require-uv
35-
uv sync --extra dev
36-
uv run pre-commit install
35+
uv sync --inexact --extra dev
36+
uv run pre-commit install
37+
38+
# run tests with coverage and show a coverage report
39+
coverage:
40+
coverage run -m pytest
41+
coverage report
3742

3843
# clean build artifacts and caches
3944
clean:
40-
rm -rf .venv .pytest_cache .mypy_cache .ruff_cache
41-
find . -type d -name "__pycache__" -exec rm -r {} +
45+
rm -rf .venv .pytest_cache .mypy_cache .ruff_cache
46+
find . -type d -name "__pycache__" -exec rm -r {} +
47+
48+
# list available recipes
49+
help:
50+
just --list
51+
52+
alias fmt := format
53+
alias cov := coverage

template/pyproject.toml.jinja

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ keywords = [
6060
"{{ package_name }}"
6161
]
6262

63-
6463
[project.optional-dependencies]
6564
test = ["pytest"]
66-
dev = ["pytest", "black", "ruff", "pre-commit"]
65+
dev = ["pytest", "ruff", "pre-commit", "coverage"]
6766

6867
[project.urls]
6968
Repository = "{{ repository_url }}"
@@ -74,17 +73,25 @@ Homepage = "{{ repository_url }}"
7473
requires = ["hatchling"]
7574
build-backend = "hatchling.build"
7675

77-
[tool.hatch.build.targets.wheel]
78-
packages = ["{{ package_name }}"]
76+
[tool.hatch.envs.test]
77+
features = ["test"]
78+
installer = "uv"
7979

80-
[tool.black]
81-
line-length = 100
82-
target-version = [
83-
{%- for target in black_target_versions(python_min_version, python_max_version) %}
84-
'{{ target }}',
80+
[[tool.hatch.envs.test.matrix]]
81+
python = [
82+
{%- for version in py_versions_range(python_min_version, python_max_version) %}
83+
"{{ version }}",
8584
{%- endfor %}
8685
]
8786

87+
[tool.hatch.envs.test.scripts]
88+
test = "pytest {args}"
89+
coverage = "coverage run -m pytest {args}"
90+
91+
92+
[tool.hatch.build.targets.wheel]
93+
packages = ["{{ package_name }}"]
94+
8895
[tool.ruff]
8996
line-length = 100
9097

@@ -158,32 +165,9 @@ ignore = [
158165
"UP007",
159166
"UP038",
160167
]
161-
isort = { known-first-party = ["{{ package_name }}", 'tests'] }
162-
pydocstyle = { convention = 'google' }
163-
164168
exclude = [
165-
".bzr",
166-
".direnv",
167-
".eggs",
168-
".git",
169-
".hg",
170-
".mypy_cache",
171-
".nox",
172-
".pants.d",
173-
".pytype",
174-
".ruff_cache",
175-
".svn",
176-
".tox",
177-
".venv",
178-
"__pypackages__",
179-
"_build",
180-
"buck-out",
181169
"build",
182-
"dist",
183-
"node_modules",
184-
"venv",
185-
"tests/*",
186-
"tests/**/*",
170+
"tests/**",
187171
]
188172

189173
[tool.ruff.lint.per-file-ignores]
@@ -196,18 +180,20 @@ exclude = [
196180
quote-style = "double"
197181
indent-style = "space"
198182
skip-magic-trailing-comma = false
199-
line-ending = "auto"
183+
line-ending = "lf"
200184

201-
[tool.hatch.envs.test]
202-
features = ["test"]
203-
installer = "uv"
185+
[tool.ruff.lint.isort]
186+
known-first-party = ["{{ package_name }}", "tests"]
204187

205-
[[tool.hatch.envs.test.matrix]]
206-
python = [
207-
{%- for version in py_versions_range(python_min_version, python_max_version) %}
208-
"{{ version }}",
209-
{%- endfor %}
210-
]
188+
[tool.ruff.lint.pydocstyle]
189+
convention = "google"
211190

212-
[tool.hatch.envs.test.scripts]
213-
test = "pytest -v"
191+
[tool.coverage.run]
192+
source = ["{{ package_name }}"]
193+
branch = true
194+
195+
[tool.coverage.report]
196+
omit = [
197+
"tests/*",
198+
"tests/**",
199+
]

0 commit comments

Comments
 (0)