Add pre-commit package for django app#867
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Docker-backed pre-commit hooks for Ruff, isort, Black, and Flake8 limited to Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant PC as Pre-commit
participant Dock as Docker
participant Repo as Repository (/workspace)
participant Tool as Formatter/Linter
Dev->>PC: git commit (triggers hooks)
PC->>Dock: start container (mount Repo at /workspace)
Dock->>Repo: read changed files matching ^src/django/.*\.py$
Dock->>Tool: invoke tool via --entrypoint (use /workspace configs)
Tool-->>Dock: apply fixes / return status
Dock-->>PC: return results
PC-->>Dev: allow or block commit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@README.md`:
- Line 249: Clarify the pre-commit installation context around the existing `pip
install pre-commit` and `pre-commit install` instructions and the note that
hooks run in Docker: explicitly state whether developers should install
pre-commit locally (system/virtualenv) for local pre-commit execution, or
whether the repository relies on Docker to run hooks (or both), and update the
README around the `pip install pre-commit` and `pre-commit install` lines and
the "hooks run in Docker" sentence to one concise statement that explains the
recommended developer workflow (e.g., install pre-commit locally for immediate
checks and note that CI/Docker also runs the hooks), plus an optional command
for running hooks inside the Docker image if applicable.
- Around line 247-258: Add a prerequisite step to the README stating that the
Docker image must be built before running pre-commit hooks that execute inside
the django container; specifically, before describing the "Local first wall" /
editor setup, add a short note telling developers to run the project Docker
build (e.g., docker compose build or the repository's docker build command) so
that the pre-commit invocation (pre-commit run --all-files) and hooks defined in
.pre-commit-config.yaml that run inside the django container will not fail.
- Line 250: Update the README to clarify the .venv virtual environment: state
whether .venv is created automatically by the project setup or must be created
manually, add explicit steps to create it (e.g., python -m venv .venv) and how
to activate it, and explain how editor settings should point to .venv's Python
interpreter and formatter (Black/Ruff) when using local venv vs Docker; also
mention interaction with the existing ./scripts/start_local_dev flow (that it
uses Docker and does not create .venv) so contributors know when to create .venv
locally.
🧹 Nitpick comments (1)
README.md (1)
255-255: Fix extra leading space.There's an extra space before "Example settings file" in the bullet point.
Minor formatting fix
-- Example settings file: `.vscode/example-settings.json`. Copy to `.vscode/settings.json` to apply. +- Example settings file: `.vscode/example-settings.json`. Copy to `.vscode/settings.json` to apply.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 12-24: The TOC entries contain fragment identifiers that don't
match the rendered heading IDs (causing markdownlint MD051); update the link
fragments to exactly match the generated anchors for the headings (for example
"Local Development" and "Running e2e (Playwright) and integration tests") or add
explicit HTML anchors directly above those headings so the fragments resolve;
ensure any special characters/emojis in headings (e.g., "Hot Reloading 🔥",
"Scripts 🧰", "Tools ⚒️") are either removed or encoded in the TOC links to
match the renderer's ID generation and then verify the updated refs in the
README TOC (the visible heading texts are the unique identifiers to match).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 267-268: Update the README so the referenced settings file is
consistent: change the reference to `.vscode/settings.json` in the sentence
about enabling format on save and Ruff fixes to point to the example file
`.vscode/example-settings.json` (or explicitly state "see
`.vscode/example-settings.json` and copy it to `.vscode/settings.json`") so it
matches the following line that instructs copying the example file; update the
mention in the same paragraph that lists Black, `source.fixAll`,
`source.fixAll.ruff`, and virtualenv binary paths to reference the example file
name `.vscode/example-settings.json`.
|



Add Dockerized pre-commit hooks for Python lint/format
ruff,isort,blackto Django image and align flake8 config (88 chars, E203/W503).docker compose run djangowith repo mount and proper config paths.Add
.vscode/example-settings.jsonfor VSCode / Cursor.Ruff, Black, and isort play different roles:
Black: single, opinionated formatter for consistent layout (spacing/line breaks/quotes), no lint logic.Ruff: fast linter with many flake8-style rules and auto-fixes (unused imports/vars, style cleanups); acts as a lightweight guard before CI.isort: deterministic import ordering. Ruff can sort imports, but we keep isort to match our CI chain and avoid config drift.We keep all three so formatting, linting, and import ordering stay consistent locally and in CI;
flake8remains as a final parity check.