Skip to content

Commit 4be92bb

Browse files
committed
refactor(template): simplify Python template configuration
Consolidate generated mise settings, trim legacy Copier migrations, and rename workflow files for clearer Python-specific automation. This also updates Ruff defaults and the lazy-loader dependency so new projects match the current template layout and tool behavior.
1 parent 92f8871 commit 4be92bb

9 files changed

Lines changed: 53 additions & 79 deletions

File tree

copier.yaml

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,21 @@ _external_data:
99

1010
_envops:
1111
comment_start_string: "# {#"
12-
line_statement_prefix: "# %%"
13-
14-
_migrations: &migrations
15-
- rm --force --recursive --verbose '.config/copier/mise/tasks'
16-
- rm --force --verbose '.config/copier/direnv/00-python.sh'
17-
- rm --force --verbose '.config/copier/direnv/10-python.sh'
18-
- rm --force --verbose '.config/copier/mise-tasks/bench.sh'
19-
- rm --force --verbose '.config/copier/mise-tasks/gen/_default'
20-
- rm --force --verbose '.config/copier/mise-tasks/gen/init.sh'
21-
- rm --force --verbose '.config/copier/mise-tasks/test.sh'
22-
- rm --force --verbose '.config/copier/mise/scripts/setup-python.sh'
23-
- rm --force --verbose '.config/copier/python.just'
24-
- rm --force --verbose '.config/direnv/10-python.sh'
25-
- rm --force --verbose '.config/mise/conf.d/00-python.toml'
26-
- rm --force --verbose '.github/copier/.copier-answers.python.yaml'
27-
- rm --force --verbose '.github/copier/mkdocs.yaml'
28-
- rm --force --verbose '.github/linters/.ruff.toml'
29-
- rm --force --verbose '.github/linters/pyrightconfig.json'
30-
- rm --force --verbose '.github/workflows/build.yaml' # TODO: remove this migration in future
31-
- rm --force --verbose '.github/workflows/docs-dev.yaml'
32-
- rm --force --verbose '.github/workflows/docs-stable.yaml'
33-
- rm --force --verbose '.github/workflows/docs-test.yaml'
34-
- rm --force --verbose '.github/workflows/shared-docs.yaml'
35-
- rm --force --verbose '.github/workflows/shared-release.yaml'
36-
- rm --force --verbose 'docs/css/fonts.css'
37-
- rm --force --verbose 'docs/css/mkdocstrings/api-autonav.css'
38-
- rm --force --verbose 'docs/css/mkdocstrings/material.css'
39-
- rm --force --verbose 'docs/css/mkdocstrings/syntax-highlight-in-signatures.css'
40-
- rm --force --verbose 'docs/javascript/mathjax.js'
41-
- rm --force --verbose 'docs/scripts/gen-ref-pages.py'
42-
- rm --force --verbose 'docs/SUMMARY.md'
43-
- rm --force --verbose 'typings/__builtins__.pyi'
12+
13+
_migrations:
14+
- command: rm --force '.github/workflows/bench.yaml'
15+
version: v0.2.0
16+
- command: rm --force '.github/workflows/docs.yaml'
17+
version: v0.2.0
18+
- command: rm --force '.github/workflows/release.yaml'
19+
version: v0.2.0
20+
- command: rm --force '.github/workflows/test.yaml'
21+
version: v0.2.0
4422

4523
_skip_if_exists:
46-
- .config/mise/config.toml
4724
- .gitignore
4825
- .vscode/settings.json
49-
- docs/.nav.yml
50-
- docs/README.md
26+
- docs/
5127
- mkdocs.yaml
5228
- noxfile.py
5329
- pyproject.toml
@@ -57,8 +33,6 @@ _skip_if_exists:
5733

5834
_subdirectory: template
5935

60-
_tasks: *migrations
61-
6236
answers_file_shared:
6337
type: str
6438
default: .config/copier/.copier-answers.shared.yaml

template/.config/linters/.ruff.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# DO NOT EDIT!
44

55
builtins = ["ic"]
6-
exclude = ["_version.py"]
6+
extend-exclude = ["_version.py"]
77
fix = true
88
show-fixes = true
99

1010
[format]
1111
docstring-code-format = true
12+
skip-magic-trailing-comma = true
1213

1314
[lint]
1415
explicit-preview-rules = true
@@ -50,7 +51,7 @@ select = ["ALL"]
5051
[lint.flake8-annotations]
5152
allow-star-arg-any = true
5253

53-
[lint.flake8-import-conventions.aliases]
54+
[lint.flake8-import-conventions.extend-aliases]
5455
"jax.numpy" = "jnp"
5556
"jax.typing" = "jxt"
5657
"matplotlib" = "mpl"
@@ -67,6 +68,3 @@ allow-star-arg-any = true
6768

6869
[lint.pydocstyle]
6970
convention = "google"
70-
71-
[lint.pylint]
72-
max-args = 10

template/.config/mise/conf.d/10-python.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
# This file is @generated by <https://github.com/liblaf/copier-python>.
33
# DO NOT EDIT!
44

5-
[hooks]
6-
enter = { task = "install" }
5+
[hooks.enter]
6+
task = "install"
7+
8+
[task_config]
9+
includes = [".config/mise/tasks", ".config/copier/mise-tasks"]
710

811
[tasks.lint]
912
depends = ["lint:python", "lint:toml"]

template/.config/mise/config.toml

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

template/.github/workflows/bench.yaml renamed to template/.github/workflows/python-bench.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# This file is @generated by <https://github.com/liblaf/copier-python>.
22
# DO NOT EDIT!
33

4-
name: Bench
4+
name: Python > Bench
55

66
on:
77
push:
88
branches:
99
- main
1010
pull_request:
11-
workflow_dispatch:
11+
branches:
12+
- main
1213

1314
env:
1415
FORCE_COLOR: 1
@@ -26,7 +27,7 @@ jobs:
2627
uses: astral-sh/setup-uv@v7
2728
with:
2829
activate-environment: true
29-
- name: Install Dependencies
30+
- name: Install dependencies
3031
run: uv sync --active --frozen --all-packages
3132
- id: collect
3233
name: Collect
@@ -51,7 +52,7 @@ jobs:
5152
uses: astral-sh/setup-uv@v7
5253
with:
5354
activate-environment: true
54-
- name: Install Dependencies
55+
- name: Install dependencies
5556
run: uv sync --active --frozen --all-packages
5657
- name: Bench
5758
uses: CodSpeedHQ/action@v4

template/.github/workflows/docs.yaml renamed to template/.github/workflows/python-docs.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# This file is @generated by <https://github.com/liblaf/copier-python>.
22
# DO NOT EDIT!
33

4-
name: Docs
4+
name: Python > Docs
55

66
on:
77
push:
88
branches:
99
- main
1010
pull_request:
11-
workflow_dispatch:
11+
branches:
12+
- main
1213

1314
env:
1415
FORCE_COLOR: 1
@@ -25,20 +26,20 @@ jobs:
2526
- id: config
2627
name: Configure GitHub Pages
2728
uses: actions/configure-pages@v6
28-
- name: Set Environment Variables
29+
- name: Set environment variables
2930
run: echo 'SITE_URL=${{ steps.config.outputs.base_url }}' >> "$GITHUB_ENV"
3031
- name: Setup uv
3132
uses: astral-sh/setup-uv@v7
3233
with:
3334
activate-environment: true
34-
- name: Install Dependencies
35+
- name: Install dependencies
3536
run: uv sync --active --frozen --all-packages
3637
- if: hashFiles('docs/scripts/pre-build.sh') != ''
37-
name: Pre-Build
38+
name: Pre-build
3839
run: docs/scripts/pre-build.sh
3940
- name: Build
4041
run: mkdocs build
41-
- name: Upload Github Pages Artifact
42+
- name: Upload Github Pages artifact
4243
uses: actions/upload-pages-artifact@v4
4344
with:
4445
path: site
@@ -57,5 +58,5 @@ jobs:
5758
url: ${{ steps.deploy.outputs.page_url }}
5859
steps:
5960
- id: deploy
60-
name: Deploy Github Pages Site
61+
name: Deploy Github Pages site
6162
uses: actions/deploy-pages@v5

template/.github/workflows/release.yaml renamed to template/.github/workflows/python-release.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# This file is @generated by <https://github.com/liblaf/copier-python>.
22
# DO NOT EDIT!
33

4-
name: Release
4+
name: Python > Release
55

66
on:
7-
release:
8-
types:
9-
- published
10-
workflow_dispatch:
7+
push:
8+
tags:
9+
- "v[0-9]*"
1110

1211
env:
1312
FORCE_COLOR: 1
@@ -27,13 +26,13 @@ jobs:
2726
- name: Checkout
2827
uses: actions/checkout@v6
2928
- id: build
30-
name: Build and Inspect a Python Package
29+
name: Build and inspect a Python package
3130
uses: hynek/build-and-inspect-python-package@v2
3231
with:
3332
attest-build-provenance-github: true
3433

35-
publish:
36-
name: Publish
34+
pypi:
35+
name: Publish to PyPI
3736
permissions:
3837
attestations: write
3938
id-token: write
@@ -44,7 +43,7 @@ jobs:
4443
name: PyPI
4544
url: https://pypi.org/project/${{ needs.build.outputs.package-name }}/${{ needs.build.outputs.package-version }}/
4645
steps:
47-
- name: Download Artifacts
46+
- name: Download artifacts
4847
uses: actions/download-artifact@v8
4948
with:
5049
name: ${{ needs.build.outputs.artifact-name }}
@@ -56,20 +55,21 @@ jobs:
5655
print-hash: true
5756
attestations: true
5857

59-
release:
60-
name: Release
58+
github:
59+
name: GitHub Release
6160
permissions:
6261
contents: write
6362
needs:
6463
- build
6564
runs-on: ubuntu-latest
6665
steps:
67-
- name: Download Artifacts
66+
- name: Download artifacts
6867
uses: actions/download-artifact@v8
6968
with:
7069
name: ${{ needs.build.outputs.artifact-name }}
7170
path: dist
72-
- name: Upload Release Assets
71+
- name: Upload release assets
7372
uses: softprops/action-gh-release@v2
7473
with:
74+
draft: false
7575
files: dist/*

template/.github/workflows/test.yaml renamed to template/.github/workflows/python-test.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
# ref: <https://docs.codecov.com/docs/test-analytics>
55

6-
name: Test
6+
name: Python > Test
77

88
on:
99
push:
1010
branches:
1111
- main
1212
pull_request:
13-
workflow_dispatch:
13+
branches:
14+
- main
1415

1516
env:
1617
FORCE_COLOR: 1
@@ -28,7 +29,7 @@ jobs:
2829
uses: astral-sh/setup-uv@v7
2930
with:
3031
activate-environment: true
31-
- name: Install Dependencies
32+
- name: Install dependencies
3233
run: uv sync --active --frozen --all-packages
3334
- id: collect
3435
name: Collect
@@ -55,18 +56,18 @@ jobs:
5556
uses: astral-sh/setup-uv@v7
5657
with:
5758
activate-environment: true
58-
- name: Install Dependencies
59+
- name: Install dependencies
5960
run: uv sync --active --frozen --all-packages
6061
- name: Test
6162
run: nox --session '${{ matrix.session }}'
6263
- if: success() || failure()
63-
name: Upload Coverage
64+
name: Upload coverage
6465
uses: codecov/codecov-action@v6
6566
with:
6667
report_type: coverage
6768
use_oidc: true
6869
- if: success() || failure()
69-
name: Upload Test Results
70+
name: Upload test results
7071
uses: codecov/codecov-action@v6
7172
with:
7273
report_type: test_results

template/pyproject.toml.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: 3.14",
2525
"Typing :: Typed"
2626
]
27-
dependencies = ["lazy-loader>=0.1"]
27+
dependencies = ["liblaf-lazy-loader>=0.1"]
2828
dynamic = ["version"]
2929

3030
[project.urls]

0 commit comments

Comments
 (0)