Skip to content

feat: optional example, data/ML setup and protected project files - #2

Merged
jvitorcosta merged 4 commits into
mainfrom
feat/project-options
Oct 29, 2026
Merged

jvitorcosta merged 4 commits into
mainfrom
feat/project-options

Conversation

@jvitorcosta

Copy link
Copy Markdown
Owner

Adds three Copier questions, prompted by retrofitting the template into fraud-alert-explainer. All are off by default: with the defaults, a generated project is byte-for-byte the same as v0.3.0 (only .copier-answers.yml records the new answers).

Question Default Effect when changed
include_example yes No drops hello() and its tests (and the CLI's greet), keeping only __version__. The bare CLI keeps its version subcommand via a Typer callback.
include_data_science no Yes adds numpy/pandas/scikit-learn, pandas-stubs and ipykernel, a mypy override for sklearn.*, notebooks/ excluded from Ruff, data/ + artifacts/ gitignored, CLAUDE.md notes, and brew install libomp on macOS CI. Without libomp, LightGBM fails to import on macos-latest, which is what broke fraud-alert-explainer's first CI run.
protect_project_files no Yes makes copier update skip README.md, CHANGELOG.md and the package __init__.py once they exist (_skip_if_exists, with patterns that render to nothing when off).

Why only those three files are protected: copier recreates a _skip_if_exists file the project deleted (checked in copier 9.19's _main.py). So the list only holds files a project keeps but rewrites, not placeholders it might delete.

To make the data option possible: .gitignore and ci.yml became .jinja files. The CI file wraps its GitHub expressions in {% raw %} per CONTRIBUTING.

Verification (Windows, copier 9.19.1)

  • make test passes: 33 hook tests, plus four rendered variants (default, CLI, bare CLI with include_example=false, data with include_data_science + protect_project_files on), each running ruff, ruff format, mypy strict and pytest with the coverage gate. The two new variants are added to make test, so CI covers them on all three OSes.
  • make check run inside each rendered project: all four pass.
  • Default render vs --vcs-ref=v0.3.0: diff -r is identical apart from .copier-answers.yml. This caught two whitespace bugs, both fixed.
  • Data variant, with real code added (a pandas + LogisticRegression module and a test): make check passes under mypy strict. data/raw.csv stays untracked and notebooks/README.md is tracked. Both rendered workflows parse as YAML.
  • copier update test against a throwaway template clone tagged v0.9.0 → v0.9.1, where the update changes README, CHANGELOG, __init__.py and CLAUDE.md, and the project has rewritten the first three:
    • protect_project_files=true: the three project files are untouched and CLAUDE.md gets the update.
    • protect_project_files=false: the same as today, with conflict markers in all three files.
    • Opting in during the update (copier update -d protect_project_files=true on a project made without it): README kept, answer recorded.

Not verified: the macOS brew install libomp step in a rendered project's CI. It's the same step that fixed fraud-alert-explainer's macOS CI.

Release

CHANGELOG has a 0.4.0 section. After merging, tag on main: git tag -a v0.4.0 -m v0.4.0 && git push --follow-tags.

🤖 Generated with Claude Code

jvitorcosta and others added 4 commits October 29, 2026 12:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvitorcosta
jvitorcosta merged commit 0aa878f into main Oct 29, 2026
3 checks passed
@jvitorcosta
jvitorcosta deleted the feat/project-options branch October 30, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant