style: lint and format src/djehuty/web/validator.py with ruff, enforce - #184
Draft
641e16 wants to merge 9 commits into
Draft
style: lint and format src/djehuty/web/validator.py with ruff, enforce#184641e16 wants to merge 9 commits into
641e16 wants to merge 9 commits into
Conversation
* pyproject.toml: Add [tool.ruff] config (line-length 100; E, W, F, I, N, B rule sets) and a "lint" dependency group with ruff, so CI and local runs use the same version. * uv.lock: Lock ruff 0.15.21; refresh stale djehuty version (26.3.1 -> 26.3.3).
* justfile: add lint paths to enforce scope and add lint recipe
* constants.py, convenience.py, rdf.py: Apply "ruff check --fix" (import sorting, not-in comparison) and "ruff format"; wrap remaining long lines. no functional changes.
* .github/workflows/lint.yml: Add reusable workflow that runs "just lint" (ruff check + format check) via uv. * .github/workflows/ci.yml: Wire in the lint job, running in parallel with build and unit tests for fast feedback.
* justfile: ruff lives in the "lint" dependency group, not "dev", so "uv run --group dev ruff" fails on a fresh environment like CI.
* README.md: Add Linting section describing the incremental rollout and the just lint recipe. * CONTRIBUTING.md: State the enforced line length (100) and add a lint step to the code conventions.
* validator.py: Mechanical pass only ("ruff check --fix" for import
sorting, "ruff format" for layout). No functional changes; the
remaining violations are resolved in the next commit.
* validator.py: Iterate over value.values() where the key was unused (B007); keep the ValidationException name with a justified noqa comment — renaming would touch ~60 exception handlers in wsgi.py (N818), out of scope for a formatting pass. * justfile: Add src/djehuty/web/validator.py to lint_paths.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #184 +/- ##
=======================================
Coverage 17.49% 17.49%
=======================================
Files 21 21
Lines 10217 10217
Branches 1977 1977
=======================================
Hits 1787 1787
Misses 8241 8241
Partials 189 189 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Next slice of the incremental Ruff rollout (#66): lints and formats
src/djehuty/web/validator.pyand adds it to the enforced scope. Split into a mechanical commit (pureruff check --fix+ruff formatoutput, safe to skim) and a manual commit (the two violations ruff could not auto-fix, worth review).Changes
src/djehuty/web/validator.py(commit 1, mechanical): applyruff check --fix(import sorting) andruff format. No functionalchanges.
src/djehuty/web/validator.py(commit 2, manual): iterate overvalue.values()where the loop key was unused (B007); keep theValidationExceptionname with a justifiednoqa: N818comment (see Notes).justfile: add the file tolint_pathssojust lintand CI enforce it.Approval Checklist
Issue Reference
Closes #146 (part of #66)
Screenshots
Green CI run on my fork with the Lint job covering the extended scope:
https://github.com/641e16/djehuty/actions/runs/29641379402
Notes
noqa, called out explicitly:ValidationExceptionkeeps its name despite N818 (exceptions should end in "Error"). It is the base class of nine validator exceptions and is caught ~60 inwsgi.py, which is not yet in lintscope - renaming it here would drag a 10k-line unlinted file into a formatting PR. The rule stays enabled; this is a single documented exemption, revisitable when wsgi.py gets checked (if it will).for v in value.values()instead of an unused key) is behavior-identical: the loop returns the first value either way.just lintgreen on the full scope; module imports cleanly; unit tests pass.