-
Notifications
You must be signed in to change notification settings - Fork 0
Build a practical Python starter template #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0763bb4
feat(template): add package scaffold
techhouse-looper d2478d6
chore(dev): add local tooling
techhouse-looper 5f5c8c5
ci: add GitHub automation
techhouse-looper 7f226f3
docs: document the starter workflow
techhouse-looper c757e28
docs(readme): tighten project positioning
techhouse-looper 4694017
docs(readme): add a light visual accent
techhouse-looper 95c7666
feat(cli): add a small hello command
techhouse-looper e6a58b9
docs(readme): keep quickstart runnable
techhouse-looper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ## Summary | ||
|
|
||
| - What changed? | ||
| - Why does it matter? | ||
|
|
||
| ## Testing | ||
|
|
||
| - [ ] `make check` | ||
| - [ ] `make build` | ||
| - [ ] Other: | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [ ] Scope is small and reviewable | ||
| - [ ] Docs updated if needed | ||
| - [ ] No unrelated changes included | ||
|
|
||
| ## Notes | ||
|
|
||
| - Breaking changes: | ||
| - Follow-ups: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version-file: .python-version | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - name: Build wheel and sdist | ||
| run: make build | ||
| - name: Smoke-test built wheel | ||
| run: | | ||
| python -m venv /tmp/python-template-wheel-test | ||
| /tmp/python-template-wheel-test/bin/pip install dist/*.whl | ||
| /tmp/python-template-wheel-test/bin/python-template --help | ||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: python-package-dist | ||
| path: dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| quality: | ||
| name: quality (py${{ matrix.python-version }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ['3.11', '3.12', '3.13'] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - name: Sync dependencies | ||
| run: uv sync --group dev --frozen | ||
| - name: Run quality gate | ||
| run: make check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| release-artifacts: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version-file: .python-version | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - name: Build release artifacts | ||
| run: make build | ||
| - name: Upload release artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: python-template-release-${{ github.ref_name }} | ||
| path: dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *.pyo | ||
| *.pyd | ||
| *.so | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
| venv/ | ||
|
|
||
| # Packaging | ||
| build/ | ||
| dist/ | ||
| *.egg-info/ | ||
|
|
||
| # Test and coverage | ||
| .pytest_cache/ | ||
| .coverage | ||
| .coverage.* | ||
| htmlcov/ | ||
|
|
||
| # Type checking and lint caches | ||
| .pyright/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
|
|
||
| # Editors and OS | ||
| .vscode/ | ||
| .idea/ | ||
| .DS_Store | ||
|
|
||
| # AI assistant local state | ||
| .claude/ | ||
| .claude.json | ||
| .claude.json.backup* | ||
| CLAUDE.local.md | ||
| .codex/.codex-global-state.json | ||
| .codex/.omx/ | ||
| .codex/archived_sessions/ | ||
| .codex/history.jsonl | ||
| .codex/log/ | ||
| .codex/logs_*.sqlite | ||
| .codex/logs_*.sqlite-* | ||
| .codex/session_index.jsonl | ||
| .codex/sessions/ | ||
| .codex/shell_snapshots/ | ||
| .codex/sqlite/ | ||
| .codex/state_*.sqlite | ||
| .codex/tmp/ | ||
|
|
||
| # Local env | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Project-local automation state | ||
| .omx/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| repos: | ||
| - repo: local | ||
| hooks: | ||
| - id: ruff-format | ||
| name: ruff format | ||
| entry: uv run ruff format | ||
| language: system | ||
| types: [python] | ||
| - id: ruff-check | ||
| name: ruff check | ||
| entry: uv run ruff check --fix | ||
| language: system | ||
| types: [python] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Yujeong | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| PACKAGE ?= python_template | ||
| SRC_DIRS := src tests | ||
|
|
||
| .PHONY: help setup setup-dev lock update format format-check lint lint-fix typecheck test test-cov check build clean | ||
|
|
||
| .DEFAULT_GOAL := help | ||
|
|
||
| help: ## Show available tasks | ||
| @awk 'BEGIN {FS = ":.*##"; printf "\nAvailable tasks:\n\n"} /^[a-zA-Z0-9_.-]+:.*##/ {printf " %-20s %s\n", $$1, $$2} END {print ""}' $(MAKEFILE_LIST) | ||
|
|
||
| setup: ## Install the base project environment | ||
| uv sync | ||
|
|
||
| setup-dev: ## Install developer dependencies | ||
| uv sync --group dev | ||
|
|
||
| lock: ## Refresh uv.lock without upgrading pinned packages | ||
| uv lock | ||
|
|
||
| update: ## Upgrade dependencies and refresh uv.lock | ||
| uv lock --upgrade | ||
|
|
||
| format: ## Format the codebase with Ruff | ||
| uv run ruff format $(SRC_DIRS) | ||
|
|
||
| format-check: ## Check formatting without modifying files | ||
| uv run ruff format --check $(SRC_DIRS) | ||
|
|
||
| lint: ## Run Ruff lint checks | ||
| uv run ruff check $(SRC_DIRS) | ||
|
|
||
| lint-fix: ## Run Ruff lint checks and apply safe fixes | ||
| uv run ruff check --fix $(SRC_DIRS) | ||
|
|
||
| typecheck: ## Run Pyright type checking | ||
| uv run pyright | ||
|
|
||
| test: ## Run tests | ||
| PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run pytest | ||
|
|
||
| test-cov: ## Run tests with coverage | ||
| PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run pytest --cov=$(PACKAGE) --cov-report=term-missing | ||
|
|
||
| check: format-check lint typecheck test ## Run the full local quality gate | ||
|
|
||
| build: ## Build wheel and sdist artifacts | ||
| uv build | ||
|
|
||
| clean: ## Remove local build and tool caches | ||
| rm -rf .venv .pytest_cache .pyright .ruff_cache .mypy_cache build dist htmlcov .coverage .coverage.* | ||
| find . -type d -name '__pycache__' -prune -exec rm -rf {} + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,84 @@ | ||
| # python-template | ||
| # python-template 🐍 | ||
|
|
||
| A small Python starter with strict defaults, fast feedback, and a package layout that scales past | ||
| the first weekend. | ||
|
|
||
| The goal is simple: start from a clean baseline, keep the toolchain boring, and make quality checks | ||
| cheap enough to run all the time. | ||
|
|
||
| ## Defaults | ||
|
|
||
| - `uv` for dependency and lockfile management | ||
| - `src/` layout with Hatchling packaging | ||
| - Click for a minimal CLI entry point | ||
| - Ruff, Pyright, and pytest as the default quality bar | ||
| - GitHub Actions for CI, build validation, and release artifacts | ||
|
|
||
| ## Quickstart | ||
|
|
||
| ```bash | ||
| make setup-dev | ||
| make check | ||
| uv run python -m python_template --help | ||
| uv run python -m python_template hello | ||
| ``` | ||
|
|
||
| Sample output: | ||
|
|
||
| ```text | ||
| Let's build something fun, Yujeong. | ||
| ``` | ||
|
|
||
| ## Core commands | ||
|
|
||
| | Command | Purpose | | ||
| | --- | --- | | ||
| | `make setup` | Install runtime dependencies | | ||
| | `make setup-dev` | Install runtime and development dependencies | | ||
| | `make format` | Format the codebase with Ruff | | ||
| | `make lint` | Run Ruff lint checks | | ||
| | `make lint-fix` | Run Ruff and apply safe fixes | | ||
| | `make typecheck` | Run Pyright in strict mode | | ||
| | `make test` | Run pytest | | ||
| | `make test-cov` | Run pytest with coverage | | ||
| | `make check` | Run format, lint, typecheck, and tests | | ||
| | `make build` | Build the wheel and sdist | | ||
| | `make lock` | Refresh `uv.lock` without upgrading | | ||
| | `make update` | Upgrade dependencies and refresh `uv.lock` | | ||
|
|
||
| ## Project layout | ||
|
|
||
| ```text | ||
| . | ||
| ├── .github/workflows/ | ||
| ├── src/python_template/ | ||
| ├── tests/ | ||
| ├── .pre-commit-config.yaml | ||
| ├── Makefile | ||
| ├── pyproject.toml | ||
| └── uv.lock | ||
| ``` | ||
|
|
||
| ## Quality defaults | ||
|
|
||
| This template is intentionally strict by default: | ||
|
|
||
| - **Ruff** enforces formatting, imports, docstrings, naming, typing hygiene, and common bug-prone | ||
| patterns. | ||
| - **Pyright** runs in `strict` mode. | ||
| - **pytest** is the default regression layer. | ||
|
|
||
| If a real project constraint justifies relaxing a rule, change it deliberately. The default posture | ||
| is to keep the baseline tight. | ||
|
|
||
| ## GitHub Actions | ||
|
|
||
| The repository ships with three focused workflows: | ||
|
|
||
| - `ci.yml` — lint, typecheck, and test on Python 3.11–3.13 | ||
| - `build.yml` — build the package and smoke-test the generated wheel | ||
| - `release.yml` — build and upload release artifacts for version tags | ||
|
|
||
| ## License | ||
|
|
||
| MIT. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.