Skip to content

feat(grader): venv hygiene checks + Python .gitignore#5

Open
lassebenni wants to merge 1 commit into
feat/autograder-improvementsfrom
feat/week-1-venv-hygiene
Open

feat(grader): venv hygiene checks + Python .gitignore#5
lassebenni wants to merge 1 commit into
feat/autograder-improvementsfrom
feat/week-1-venv-hygiene

Conversation

@lassebenni
Copy link
Copy Markdown
Collaborator

Stacks on #4 (feat/autograder-improvements). Rebase to main once #4 lands.

Summary

  • .gitignore: adds a Python section (.venv/, venv/, env/, ENV/, __pycache__/, *.pyc, .pytest_cache/, .ruff_cache/, .mypy_cache/, build/dist). The template previously shipped only the GitHub Node template — students cloning it for a Python assignment had zero protection against committing a venv folder.
  • grader_lib.sh: extends the existing check_gitignore_python to also require .venv//venv/, plus two new hygiene checks following the same pattern:
    • check_no_venv_committedFAIL when git ls-files shows a tracked venv folder. Curriculum cross-link: Week 1 Ch1 Don't commit the venv folder.
    • check_lockfile_presentWARN when neither requirements.txt, uv.lock, nor pyproject.toml is at the repo root, with a nudge to pip freeze > requirements.txt.
  • test.sh: wires both into the Code Hygiene block. Scoring ladder unchanged, matching feat(autograder): shared grader_lib + 7 hygiene checks from c55 reviews #4's promise.

Why

Curriculum side: HackYourFuture/hyf-datatrack #245 teaches "commit the recipe, not the cooked meal" and updates Week 1's rubric to call these checks out. Without this PR the rubric is aspirational.

This PR intentionally does not rebuild a fresh venv from the lockfile and run the cleaner inside it. That is the natural next step (and is needed once Week 2 ships pytest/ruff deps), but for Week 1 the cleaner is stdlib-only so the rebuild would be ceremonial. I'll send a follow-up PR that wires the rebuild once we're ready to escalate the rubric beyond static checks.

Test plan

  • Ran bash .hyf/test.sh on this branch in the template repo: new checks fire ( gitignore, no venv committed, no lockfile). Score ladder unchanged.
  • Spot-check: temporarily commit an empty .venv/.gitkeep, re-run grader, confirm check_no_venv_committed FAILs.
  • Spot-check: touch requirements.txt, re-run grader, confirm check_lockfile_present PASSes.
  • CI on this PR passes the reusable grader workflow startup added in f3e4cb4.

🤖 Generated with Claude Code

Adds three grader_lib checks to surface venv hygiene problems on
every PR, and fixes the template's .gitignore so cloned student
repos don't accidentally track .venv/ or __pycache__/.

- .gitignore: add Python virtualenv folders (.venv/, venv/, env/, ENV/),
  bytecode/caches (__pycache__/, *.pyc, .pytest_cache/, .ruff_cache/,
  .mypy_cache/), and build artefacts. The template previously shipped
  the GitHub Node template only — Python students cloning it had no
  protection against committing a venv folder.

- grader_lib.sh:
  - Extend check_gitignore_python: also require .venv/ (or venv/).
  - Add check_no_venv_committed: FAILs when git ls-files shows a
    tracked .venv/, venv/, env/, or ENV/ entry. Curriculum: Week 1
    Ch1 'Don't commit the venv folder'.
  - Add check_lockfile_present: WARNs when no requirements.txt,
    uv.lock, or pyproject.toml is at the repo root, with a nudge
    to 'pip freeze > requirements.txt' inside an activated venv.

- test.sh: wire the two new checks into the Code Hygiene block,
  matching this PR series' '0-pt warnings, scoring ladder unchanged'
  rule.

Companion PR on the curriculum side:
HackYourFuture/hyf-datatrack #245.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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