Skip to content

Commit 2b9aa2e

Browse files
committed
docs: add make format guidance, clarify pre-commit vs CI separation
1 parent 04f7db5 commit 2b9aa2e

1 file changed

Lines changed: 61 additions & 27 deletions

File tree

README.md

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Every project generated from this template includes:
1919
| Linting | Ruff | Catches bugs, bad patterns, unused imports |
2020
| Type checking | Mypy | Catches type errors before runtime |
2121
| Testing | pytest + pytest-cov | Runs tests with coverage reporting |
22-
| Git hooks | pre-commit | Runs checks automatically on every commit |
22+
| Git hooks | pre-commit | Runs Ruff automatically on every commit |
2323
| CI/CD | GitHub Actions | Runs lint, type check, and tests on push/PR |
2424
| Branch strategy | three-tier | main / uat / dev enforced in CI |
2525
| GitHub templates | PR + Issue | Standardised PR and issue descriptions |
@@ -116,10 +116,10 @@ Copier asks a series of questions to configure your project. Each question
116116
has a default value -- press Enter to accept it, or type your own answer.
117117
```
118118
Project name (e.g. inflation-db)
119-
> inflation-analysis
119+
> inflation-db
120120
121121
Python package name
122-
> inflation_analysis
122+
> inflation_db
123123
124124
Author name
125125
> Kyle Ferreira
@@ -128,10 +128,10 @@ Author email
128128
> kyle.fe0212@gmail.com
129129
130130
Python version
131-
> 3.13
131+
> 3.11
132132
133133
Short project description
134-
> Analysis of exchange rate pass-through to local core inflation
134+
> A macroeconomic inflation database
135135
136136
License (MIT / Apache-2.0 / Proprietary)
137137
> MIT
@@ -162,19 +162,19 @@ Two of the prompts can be confusing at first:
162162
the folder name, `pyproject.toml`, `README.md`, and documentation. It
163163
typically uses hyphens as separators.
164164
```
165-
Example: inflation-analysis
165+
Example: inflation-db
166166
```
167167

168168
**Python package name** is the importable name of your package in Python
169169
code -- the name you use in `import` statements. Python package names cannot
170170
contain hyphens, so they use underscores instead. Copier auto-suggests this
171171
by converting your project name, so you usually just press Enter to accept it.
172172
```
173-
Example: inflation_analysis
173+
Example: inflation_db
174174
175175
# This is what gets used in code:
176-
from inflation_analysis import something
177-
import inflation_analysis
176+
from inflation_db import something
177+
import inflation_db
178178
```
179179

180180
As a rule: project name uses hyphens (how humans refer to it), package name
@@ -234,7 +234,7 @@ poetry run pre-commit install
234234
```
235235

236236
This activates the pre-commit hooks so that every time you run `git commit`,
237-
Ruff and Mypy run automatically and block the commit if there are any issues.
237+
Ruff runs automatically and blocks the commit if there are any lint issues.
238238
You only need to run this once per project, immediately after `git init`.
239239

240240
### Step 7 -- Confirm everything is working
@@ -405,24 +405,27 @@ the first time, or after pulling changes that added new dependencies to
405405
`pyproject.toml`. It installs everything into `.venv/` and updates
406406
`poetry.lock`.
407407
```bash
408-
make lint
409-
```
410-
Runs `ruff check .`. Scans all Python files for code quality issues --
411-
unused imports, bad patterns, style violations. Does not modify any files,
412-
only reports problems. Use this to see what needs fixing before committing.
413-
```bash
414408
make format
415409
```
416410
Runs `ruff format .`. Automatically rewrites your Python files to conform
417411
to the project's style rules -- indentation, line length, quote style, etc.
418-
Run this before committing to ensure consistent formatting.
412+
Always run `make format` before `git add` and `git commit`. This ensures
413+
your code is formatted before the pre-commit hooks run, avoiding the common
414+
situation where a hook auto-fixes a file mid-commit and blocks it.
415+
```bash
416+
make lint
417+
```
418+
Runs `ruff check .`. Scans all Python files for code quality issues --
419+
unused imports, bad patterns, style violations. Does not modify any files,
420+
only reports problems. Run this after `make format` to catch any remaining
421+
issues before committing.
419422
```bash
420423
make typecheck
421424
```
422425
Runs `mypy src`. Statically analyses your code for type errors without
423426
executing it. Catches bugs like passing the wrong type to a function before
424-
they cause a runtime failure. Run this after writing new code or updating
425-
function signatures.
427+
they cause a runtime failure. Mypy runs in CI on every push -- run it
428+
locally when you want early feedback on type correctness.
426429
```bash
427430
make test
428431
```
@@ -436,6 +439,12 @@ make ci
436439
Runs lint, format check, typecheck, and test in sequence. This mirrors
437440
exactly what GitHub Actions runs on every push. If `make ci` passes locally,
438441
your push will pass CI. Run this before pushing to catch issues early.
442+
```bash
443+
make pre-commit
444+
```
445+
Runs all pre-commit hooks manually across every file in the project. Useful
446+
for checking what the hooks will do before making a commit, or for applying
447+
hook fixes to files you have not staged yet.
439448

440449
---
441450

@@ -453,31 +462,56 @@ make install
453462
```bash
454463
# After writing a new function or module
455464
make typecheck # catch type errors immediately
465+
make test # confirm nothing is broken
466+
```
456467

457-
# Before committing
458-
make format # auto-fix formatting
468+
**Before every commit -- always follow this order**
469+
```bash
470+
make format # auto-fix formatting first
459471
make lint # check for any remaining issues
460-
make test # confirm nothing is broken
472+
git add .
473+
git commit -m "feat: describe what you did"
461474
```
462475

476+
Running `make format` before `git add` is important. The pre-commit hooks
477+
run Ruff automatically on commit -- if Ruff finds formatting issues it
478+
auto-fixes them and blocks the commit, requiring you to `git add` and
479+
commit again. Running `make format` first eliminates this by ensuring your
480+
code is already formatted before the hooks fire.
481+
463482
**Before pushing or opening a PR**
464483
```bash
465484
# Run the full suite to confirm everything passes
466485
make ci
486+
git push
467487
```
468488

469489
**Typical commit rhythm**
470490
```bash
471-
make format # fix formatting automatically
472-
make ci # confirm everything passes
491+
make format # fix formatting first
492+
make lint # confirm clean
473493
git add .
474494
git commit -m "feat: describe what you did"
495+
make ci # full check before pushing
475496
git push
476497
```
477498

478-
The pre-commit hooks will also run Ruff and Mypy automatically on
479-
`git commit`, so `make format` and `make lint` act as a first pass before
480-
the hooks fire.
499+
---
500+
501+
## Pre-commit hooks vs CI
502+
503+
This template separates concerns deliberately:
504+
505+
**Pre-commit hooks (run locally on every commit):**
506+
- Ruff lint and format -- fast, catches style issues immediately
507+
- Standard file checks -- trailing whitespace, end of file, yaml validity
508+
509+
**CI only (runs on GitHub on every push/PR):**
510+
- Mypy type checking -- thorough but slow, better as a gate than a blocker
511+
- Full test suite with coverage
512+
513+
This means local commits are fast and rarely blocked, while GitHub Actions
514+
acts as the strict quality gate before code reaches `main` or `uat`.
481515

482516
---
483517

0 commit comments

Comments
 (0)