Skip to content

Commit 6ddcf18

Browse files
committed
build(template): add import-linter and pytest tooling
Introduce a configurable module name so generated projects can set the import-linter root package explicitly. Also expand the template's lint and test dependencies and pytest settings to support import rules, coverage, and JUnit output more consistently in editors and CI.
1 parent f79723f commit 6ddcf18

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

copier.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ package_name:
121121
{{ project_name_slug | replace('_', '-') }}
122122
{%- endif -%}
123123
124+
module_name:
125+
type: str
126+
help: e.g. "namespace.project_name_slug", "project_name_slug"
127+
default: |-
128+
{{ package_dir | replace('/', '.') }}
129+
124130
wheel_package_dir:
125131
type: str
126132
help: e.g. "namespace/", "project_name_slug/"

template/.vscode/settings.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"**/__pycache__/": true,
44
"**/.cache/": true,
55
"**/.codspeed/": true,
6-
"**/.coverage.*": true,
76
"**/.coverage": true,
7+
"**/.coverage.*": true,
8+
"**/.grimp_cache/": true,
89
"**/.hypothesis/": true,
10+
"**/.import_lint_cache/": true,
911
"**/.nox/": true,
1012
"**/.pixi/": true,
1113
"**/.pytest_cache/": true,
@@ -16,12 +18,7 @@
1618
"**/site/": true
1719
},
1820
"python.analysis.diagnosticMode": "workspace",
19-
"python.testing.pytestArgs": [
20-
"--color=yes",
21-
"--cov",
22-
"--numprocesses",
23-
"auto"
24-
],
21+
"python.testing.pytestArgs": ["--color=yes", "--cov"],
2522
"python.testing.pytestEnabled": true,
2623
"python.testing.unittestEnabled": false,
2724
"yaml.customTags": [

template/pyproject.toml.jinja

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ dynamic = ["version"]
3838
"Source Code" = "https://github.com/{{ github_user }}/{{ github_repo }}"
3939

4040
[dependency-groups]
41-
dev = []
4241
build = ["check-wheel-contents>=0.6", "hatch>=1", "twine>=6"]
4342
docs = ["liblaf-mkdocs-preset>=0.3", "mkdocs>=1,<2"]
44-
nox = ["liblaf-nox-recipes>=0.1", "nox>=2026", "nox-uv>=0.7"]
45-
test = ["liblaf-pytest-preset>=0.1", "pytest>=9"]
43+
lint = ["import-linter[ui]>=2", "ruff>=0.15"]
44+
nox = ["liblaf-nox-recipes>=0.1", "nox>=2026"]
45+
test = ["pytest>=9", "pytest-cov>=7", "pytest-randomly>=4"]
4646

4747
[build-system]
4848
requires = ["hatch-vcs", "hatchling"]
@@ -67,9 +67,23 @@ packages = ["src/{{ wheel_package_dir }}"]
6767
[tool.hatch.version]
6868
source = "vcs"
6969

70+
[tool.importlinter]
71+
root_package = "{{ module_name }}"
72+
73+
[[tool.importlinter.contracts]]
74+
ancestors = ["{{ module_name }}"]
75+
name = "Acyclic siblings"
76+
type = "acyclic_siblings"
77+
7078
[tool.pytest]
71-
addopts = ["--doctest-modules", "--import-mode=importlib", "--showlocals"]
79+
addopts = [
80+
"--doctest-modules",
81+
"--import-mode=importlib",
82+
"--junitxml=junit.xml",
83+
"--showlocals"
84+
]
7285
consider_namespace_packages = true
86+
junit_family = "legacy"
7387
strict = true
7488
testpaths = ["benches", "src", "tests"]
7589

0 commit comments

Comments
 (0)