Skip to content

Commit dd3a229

Browse files
authored
Adopt python-project-template via Copier (#198)
* Adopt python-project-template via Copier Generate the project tooling from ahcodedev/python-project-template v0.4.0 and record the answers in .copier-answers.yml so future template changes can be pulled in with copier update. Project-specific README content, dependencies, and settings are kept. Rename Python.yml to python.yml to match the template and README badges. * Remove release workflows The project has no releases, so drop the template's Release Drafter and release workflows, label sync script, and related docs. * Remove docs site and trim gitignore The project has no releases, so drop the Zensical docs site. Replace CLAUDE.md.example with a gitignored CLAUDE.md and remove gitignore rules for tools the project doesn't use. * linter fixes * fix type errors
1 parent 1cde262 commit dd3a229

100 files changed

Lines changed: 1214 additions & 527 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.copier-answers.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_commit: v0.7.1
3+
_src_path: gh:ahcodedev/python-project-template
4+
description: Various Data Structures and Algorithm Solutions in Python
5+
github_repo: ahcodedev/python-ds-algorithms
6+
package_name: python_ds_algorithms
7+
project_name: python-ds-algorithms
8+
use_docs: false
9+
use_releases: false

‎.devcontainer/Dockerfile‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/python-3/.devcontainer/base.Dockerfile
1+
# See here for image contents: https://github.com/devcontainers/images/tree/main/src
22

3-
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4-
ARG VARIANT="3.14-bookworm"
5-
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}
3+
# Image version 3.3.2, Python 3.14, Debian bookworm. Tag and digest are updated by Dependabot.
4+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.15-bookworm@sha256:25ac34e3c1a4c5b19a89ece73ed0278e92afc1cfd25ecb51714891e82bede421
5+
6+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
7+
ARG NODE_VERSION="none"
8+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
69

710
# Just Installation
8-
COPY --from=ghcr.io/casey/just:latest /just /usr/local/bin/
11+
COPY --from=ghcr.io/casey/just:1.59.0@sha256:014cbe6e6de678864004e2fd8b0405f77ce43b20b225e816feb330f2fb575c01 /just /usr/local/bin/
912

1013
# uv Installation
11-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
14+
COPY --from=ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 /uv /uvx /usr/local/bin/
1215

1316
# [Optional] Uncomment this section to install additional OS packages.
1417
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1518
# && apt-get -y install --no-install-recommends <your-package-list-here>
1619

1720
# [Optional] Uncomment this line to install global node packages.
18-
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
21+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

‎.devcontainer/devcontainer.json‎

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/devcontainers/images/tree/main/src/
2+
// https://github.com/devcontainers/images/tree/main/src
33
{
44
"name": "Python 3",
55
"build": {
66
"dockerfile": "Dockerfile",
77
"context": "..",
88
"args": {
9-
"VARIANT": "3.14-bookworm",
9+
// The Python version is pinned in the Dockerfile's FROM line (tag + digest).
10+
// Options
1011
"NODE_VERSION": "none"
1112
}
1213
},
1314

1415
// Configure tool-specific properties.
1516
"customizations": {
16-
// Configure properties specific to VS Code.
1717
"vscode": {
1818
// Set *default* container specific settings.json values on container create.
1919
"settings": {
2020
"python.autoComplete.extraPaths": ["/workspaces"],
21-
"python.defaultInterpreterPath": "/usr/local/bin/python",
22-
"editor.tabSize": 4,
23-
"files.autoSave": "afterDelay",
24-
"files.trimTrailingWhitespace": true,
25-
"terminal.integrated.localEchoStyle": "dim",
26-
"[python]": {
27-
"editor.defaultFormatter": "charliermarsh.ruff",
28-
"editor.formatOnSave": true,
29-
"editor.codeActionsOnSave": {
30-
"source.fixAll.ruff": "explicit",
31-
"source.organizeImports.ruff": "explicit"
32-
}
21+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
3322
},
3423

3524
// Add the IDs of extensions you want installed when the container is created.
36-
"extensions": [
37-
"Anthropic.claude-code",
38-
"DavidAnson.vscode-markdownlint",
39-
"ms-python.python",
40-
"ms-python.vscode-pylance",
41-
"ms-vscode-remote.remote-containers",
42-
"charliermarsh.ruff"
43-
]
25+
"extensions": []
4426
}
4527
},
4628

@@ -51,5 +33,8 @@
5133
"postCreateCommand": "uv sync --all-groups",
5234

5335
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
54-
"remoteUser": "vscode"
36+
"remoteUser": "vscode",
37+
"features": {
38+
"ghcr.io/devcontainers/features/github-cli:1": "latest"
39+
}
5540
}

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.devcontainer/* -linguist-detectable
2-
.github/** -linguist-detectable
2+
.github/** -linguist-detectable

‎.github/dependabot.yml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Dependabot configuration.
2+
# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
3+
version: 2
4+
5+
updates:
6+
# GitHub Actions used in .github/workflows (updates SHA pins and their version comments)
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
cooldown:
12+
default-days: 7
13+
labels: ["dependencies"]
14+
groups:
15+
github-actions:
16+
update-types: ["minor", "patch"]
17+
18+
# Python dependencies in pyproject.toml / uv.lock
19+
- package-ecosystem: "uv"
20+
directory: "/"
21+
schedule:
22+
interval: "weekly"
23+
cooldown:
24+
default-days: 7
25+
labels: ["dependencies"]
26+
groups:
27+
python-minor-and-patch:
28+
update-types: ["minor", "patch"]
29+
30+
# Base image in .devcontainer/Dockerfile
31+
- package-ecosystem: "docker"
32+
directory: "/.devcontainer"
33+
schedule:
34+
interval: "weekly"
35+
cooldown:
36+
default-days: 7
37+
labels: ["dependencies"]
38+
39+
# Features in .devcontainer/devcontainer.json
40+
- package-ecosystem: "devcontainers"
41+
directory: "/"
42+
schedule:
43+
interval: "weekly"
44+
cooldown:
45+
default-days: 7
46+
labels: ["dependencies"]

‎.github/pull_request_template.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Summary
2+
3+
<!-- What does this PR change and why? -->
4+
5+
## Related Issues
6+
7+
<!-- e.g. Closes #123 -->
8+
9+
## Checklist
10+
11+
- [ ] `just lint` passes
12+
- [ ] `just coverage` passes
13+
- [ ] Tests added or updated for the change
14+
- [ ] `README.md` updated if needed

‎.github/workflows/Python.yml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Dependabot Auto-Merge
2+
3+
# Enables auto-merge on Dependabot PRs for minor and patch updates. The PR merges once
4+
# required status checks pass. Needs "Allow auto-merge" enabled in the repo settings.
5+
6+
on:
7+
pull_request:
8+
types: [ opened, reopened, synchronize ]
9+
10+
permissions: {}
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
jobs:
17+
auto-merge:
18+
if: github.event.pull_request.user.login == 'dependabot[bot]'
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
steps:
25+
- name: Fetch Dependabot metadata
26+
id: metadata
27+
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
28+
29+
- name: Enable auto-merge
30+
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
31+
env:
32+
GH_TOKEN: ${{ github.token }}
33+
PR_URL: ${{ github.event.pull_request.html_url }}
34+
run: |
35+
gh pr merge --auto --squash "$PR_URL"

‎.github/workflows/python.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Python CI Checks
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
code-check-and-unit-test:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
permissions:
20+
contents: read
21+
steps:
22+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23+
with:
24+
persist-credentials: false
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
27+
with:
28+
enable-cache: false
29+
version: ">=0.13,<0.14"
30+
- name: Setup environment
31+
run: |
32+
uv tool install rust-just==1.59.0
33+
uv tool install actionlint-py==1.7.12.25
34+
uv tool install yamllint==1.38.0
35+
just sync
36+
- name: Lint
37+
run: |
38+
just ci-lint
39+
- name: Spell check
40+
uses: crate-ci/typos@276087d9a4f06398b3e04825487805e2d7375888 # v1.52.2
41+
- name: Unit tests
42+
run: |
43+
just coverage
44+
markdownlint:
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 15
47+
permissions:
48+
contents: read
49+
steps:
50+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51+
with:
52+
persist-credentials: false
53+
# Keep markdownlint-cli2 in step with the VS Code markdownlint extension
54+
- name: Markdownlint
55+
uses: DavidAnson/markdownlint-cli2-action@21c1be1b93ad9ed58fa840aacc3f279cde2a72ff # v24.2.0
56+
with:
57+
globs: "**/*.md"

‎.github/workflows/security.yml‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: GitHub Actions Security Analysis
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
zizmor:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
permissions:
20+
contents: read # only needed for private or internal repos
21+
actions: read # only needed for private or internal repos
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
persist-credentials: false
27+
28+
- name: Run zizmor
29+
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
30+
with:
31+
advanced-security: false
32+
pip-audit:
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 15
35+
permissions:
36+
contents: read
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40+
with:
41+
persist-credentials: false
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
44+
with:
45+
enable-cache: false
46+
version: ">=0.13,<0.14"
47+
- name: Setup environment
48+
run: |
49+
uv tool install rust-just==1.59.0
50+
just sync
51+
- name: Audit dependencies
52+
run: |
53+
just audit
54+
betterleaks:
55+
runs-on: ubuntu-latest
56+
timeout-minutes: 15
57+
permissions:
58+
contents: read # needed to check out a private repo
59+
steps:
60+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
61+
with:
62+
persist-credentials: false
63+
fetch-depth: 0
64+
# betterleaks has no official action or PyPI package, so it is built from source
65+
- name: Install Go
66+
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
67+
with:
68+
go-version: stable
69+
cache: false
70+
- name: Install betterleaks
71+
run: |
72+
go install github.com/betterleaks/betterleaks@v1.10.1
73+
- name: Scan git history for secrets
74+
run: |
75+
"$(go env GOPATH)/bin/betterleaks" git --redact .

0 commit comments

Comments
 (0)