Skip to content

Commit e9d0397

Browse files
authored
Add Prek, Markdownlint configuration. Update project structure. (#15)
* Add Prek, Markdownlint configuration. Update project structure. * Fix UV
1 parent 58b5a5d commit e9d0397

15 files changed

Lines changed: 180 additions & 59 deletions

‎.devcontainer/devcontainer.json‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,11 @@
2121
// Set *default* container specific settings.json values on container create.
2222
"settings": {
2323
"python.autoComplete.extraPaths": ["/workspaces"],
24-
"python.defaultInterpreterPath": "/usr/local/bin/python",
25-
"editor.tabSize": 4,
26-
"files.autoSave": "afterDelay",
27-
"files.trimTrailingWhitespace": true,
28-
"terminal.integrated.localEchoStyle": "dim",
29-
"[python]": {
30-
"editor.defaultFormatter": "charliermarsh.ruff",
31-
"editor.formatOnSave": true,
32-
"editor.codeActionsOnSave": {
33-
"source.fixAll.ruff": "explicit",
34-
"source.organizeImports.ruff": "explicit"
35-
}
36-
},
37-
"python.testing.pytestArgs": [
38-
"tests"
39-
],
40-
"python.testing.unittestEnabled": false,
41-
"python.testing.pytestEnabled": true
24+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
4225
},
4326

4427
// Add the IDs of extensions you want installed when the container is created.
45-
"extensions": [
46-
"Anthropic.claude-code",
47-
"charliermarsh.ruff",
48-
"DavidAnson.vscode-markdownlint",
49-
"ms-python.python",
50-
"ms-python.vscode-pylance"
51-
]
28+
"extensions": []
5229
}
5330
},
5431

‎.github/pull_request_template.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Summary
2+
3+
<!-- What does this PR change and why? -->
4+
5+
## Related Issues
6+
7+
<!-- e.g. Closes #123 -->
8+
9+
## Type of Change
10+
11+
- [ ] Bug fix
12+
- [ ] New feature
13+
- [ ] Refactor / cleanup
14+
- [ ] Documentation
15+
- [ ] Build / CI / tooling
16+
17+
## Checklist
18+
19+
- [ ] `just lint` passes
20+
- [ ] `just test` passes
21+
- [ ] Tests added or updated for the change
22+
- [ ] `README.md` / `CHANGELOG.md` updated if needed

‎.github/workflows/python.yml‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,19 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v7
14-
- name: Setup Python
15-
uses: actions/setup-python@v6
16-
with:
17-
python-version: "3.14"
1814
- name: Setup just
1915
uses: extractions/setup-just@v3
2016
- name: Install uv
21-
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
17+
uses: astral-sh/setup-uv@v1
2218
with:
2319
enable-cache: true
20+
version: latest
2421
- name: Setup environment
2522
run: |
2623
just sync
2724
- name: Lint
2825
run: |
29-
just lint
26+
just ci-lint
3027
- name: Unit tests
3128
run: |
3229
just test

‎.gitignore‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
# OS Stuff
7+
.DS_Store
8+
69
# C extensions
710
*.so
811

@@ -81,16 +84,6 @@ target/
8184
profile_default/
8285
ipython_config.py
8386

84-
# pyenv
85-
# .python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
9487
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
9588
__pypackages__/
9689

@@ -133,3 +126,6 @@ dmypy.json
133126

134127
# Claude
135128
.claude/*.local.*
129+
130+
# Dev Container
131+
.devcontainer/devcontainer-lock.json

‎.markdownlint-cli2.jsonc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
// Files excluded from markdown linting (glob syntax)
3+
"ignores": [
4+
".github/pull_request_template.md"
5+
]
6+
}

‎.vscode/settings.json‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2-
"editor.tabSize": 4,
3-
"files.autoSave": "afterDelay",
4-
"files.trimTrailingWhitespace": true,
5-
"terminal.integrated.localEchoStyle": "dim",
6-
"[python]": {
7-
"editor.defaultFormatter": "charliermarsh.ruff",
8-
"editor.formatOnSave": true,
9-
"editor.codeActionsOnSave": {
10-
"source.fixAll.ruff": "explicit",
11-
"source.organizeImports.ruff": "explicit"
2+
"editor.tabSize": 4,
3+
"files.autoSave": "afterDelay",
4+
"files.exclude": {
5+
"**/.git": false
6+
},
7+
"files.trimTrailingWhitespace": true,
8+
"terminal.integrated.localEchoStyle": "dim",
9+
"[python]": {
10+
"editor.defaultFormatter": "charliermarsh.ruff",
11+
"editor.formatOnSave": true,
12+
"editor.codeActionsOnSave": {
13+
"source.fixAll.ruff": "explicit",
14+
"source.organizeImports.ruff": "explicit"
1215
}
1316
},
1417
"python.testing.pytestArgs": [

‎CLAUDE.md.example‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CLAUDE.md
2+
3+
Python project template using `uv` for environment/dependency management and `just` as the command runner.
4+
5+
## Commands
6+
7+
- `just sync` - install all dependency groups into `.venv`
8+
- `just lint` - type check (ty), lint + autofix (ruff), format (ruff), spell check (codespell)
9+
- `just ci-lint` - same checks without modifying files (used to verify, not fix)
10+
- `just test` - run pytest with coverage (fails under 98%)
11+
- `uv add <pkg>` / `uv add --dev <pkg>` - add a runtime / dev dependency (never edit `uv.lock` by hand)
12+
- `uv run example` - run the app entry point
13+
14+
Run `just lint` and `just test` before considering a change done.
15+
16+
## Layout
17+
18+
- `src/example/` - the package (src layout, built with `uv_build`, installed editable by `uv sync`)
19+
- `src/example/__init__.py` - `main()` entry point, exposed as the `example` script
20+
- `tests/` - pytest tests; import the package as `from example.<module> import ...`
21+
- `prek.toml` - git hook config (`prek install` to enable)
22+
23+
## Conventions
24+
25+
- Python >= 3.14; ruff line length 100, double quotes
26+
- Docstrings required in `src/` (ruff `D` rules), not in `tests/`
27+
- Type hints on public functions; code must pass `ty check`
28+
- Renaming the project means updating `[project] name`, the `src/<name>/` folder, and `[project.scripts]` together

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Python Project Template ![](https://github.com/ahcode0919/python-project-template/actions/workflows/ci.yml/badge.svg?branch=main)
1+
# Python Project Template ![](https://github.com/ahcode0919/python-project-template/actions/workflows/python.yml/badge.svg?branch=main)
22

33
Baseline Python project template
44

‎justfile‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
ci-lint:
2+
uv run ty check
3+
uv run ruff check .
4+
uv run ruff format --check .
5+
uv run codespell
16
lint:
7+
uv run ty check
28
uv run ruff check . --fix
39
uv run ruff format .
410
uv run codespell
511
sync:
612
uv sync --all-groups
713
test:
8-
uv run pytest
14+
uv run pytest

‎prek.toml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Configuration file for `prek`, a git hook framework written in Rust.
2+
# See https://prek.j178.dev for more information.
3+
#:schema https://www.schemastore.org/prek.json
4+
5+
[[repos]]
6+
repo = "builtin"
7+
hooks = [
8+
{ id = "trailing-whitespace" },
9+
{ id = "end-of-file-fixer" },
10+
{ id = "check-added-large-files" },
11+
{ id = "check-yaml" },
12+
{
13+
id = "check-json",
14+
exclude = "devcontainer.json"
15+
}
16+
]
17+
18+
[[repos]]
19+
repo = "local"
20+
hooks = [
21+
{
22+
id = "ci-lint",
23+
name = "lint codebase",
24+
language = "system",
25+
entry = "just ci-lint",
26+
pass_filenames = false
27+
},
28+
{
29+
id = "unit-tests",
30+
name = "unit tests",
31+
language = "system",
32+
entry = "just test",
33+
pass_filenames = false
34+
}
35+
]

0 commit comments

Comments
 (0)