Skip to content

style: lint and format src/djehuty/web/validator.py with ruff, enforce - #184

Draft
641e16 wants to merge 9 commits into
4TUResearchData:mainfrom
641e16:wip-lint-66-146-ruff-validator
Draft

style: lint and format src/djehuty/web/validator.py with ruff, enforce#184
641e16 wants to merge 9 commits into
4TUResearchData:mainfrom
641e16:wip-lint-66-146-ruff-validator

Conversation

@641e16

@641e16 641e16 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Note: Stacked on #173. only the last two commits are new here;
I'll rebase onto main once #173 merges.

Summary

Next slice of the incremental Ruff rollout (#66): lints and formats src/djehuty/web/validator.py and adds it to the enforced scope. Split into a mechanical commit (pure ruff check --fix + ruff format output, 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): apply ruff check --fix (import sorting) and ruff format. No functional
    changes.
  • src/djehuty/web/validator.py (commit 2, manual): iterate over value.values() where the loop key was unused (B007); keep the ValidationException name with a justified noqa: N818 comment (see Notes).
  • justfile: add the file to lint_paths so just lint and CI enforce it.

Approval Checklist

  • I agree to follow Djehuty's code of conduct.
  • I have read and I have follow the code contribution workflow.
  • Code style and conventions were respected.
  • Documentation has been updated where needed (README, docs, or examples).
  • Review approved by at least one maintainer.
  • Merge readiness (PR is squashed into a single commit and follows the commit template).

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

  • !!! First noqa, called out explicitly: ValidationException keeps its name despite N818 (exceptions should end in "Error"). It is the base class of nine validator exceptions and is caught ~60 in wsgi.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).
  • The B007 fix (for v in value.values() instead of an unused key) is behavior-identical: the loop returns the first value either way.
  • Verified: just lint green on the full scope; module imports cleanly; unit tests pass.

641e16 added 9 commits July 14, 2026 12:59
* 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

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.92063% with 164 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.49%. Comparing base (1a4ecd1) to head (2bcba3e).

Files with missing lines Patch % Lines
src/djehuty/web/validator.py 21.35% 81 Missing ⚠️
src/djehuty/utils/convenience.py 33.33% 56 Missing and 2 partials ⚠️
src/djehuty/utils/rdf.py 56.89% 23 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[IMPROVEMENT]: Lint src/djehuty/web/validator.py

1 participant