Skip to content

Add Ruff linting + formatting for Python sources#11

Merged
tyom merged 4 commits into
mainfrom
ruff
May 23, 2026
Merged

Add Ruff linting + formatting for Python sources#11
tyom merged 4 commits into
mainfrom
ruff

Conversation

@tyom
Copy link
Copy Markdown
Owner

@tyom tyom commented May 23, 2026

Adds Ruff as the Python counterpart to the existing Prettier/svelte-check tooling on the web side. Dev/CI only — Ruff never ships, so repo-intel stays stdlib-only and single-file.

What's here

  • ruff.toml — line-length 100 (matches Prettier's printWidth), rules E,F,W,I,B,UP,SIM,C4. E501 ignored (the formatter owns width). E402 per-file-ignored for repo-intel.py, whose HELP constant intentionally precedes imports.
  • Makefilemake py-lint / py-format / py-format-check; make check runs all static gates (Prettier + Ruff + svelte-check); make format now formats Python too. Ruff runs via uvx ruff@0.14.5 (pinned, nothing installed or committed).
  • CIsetup-uv plus py-lint and py-format-check gates, alongside the existing Prettier check.
  • README — Development section documents make format/make check and refreshes the component-structure table.

Code changes

  • The two real lint findings fixed: build.py now names which placeholder is missing (was an unused loop var), and collect_local uses contextlib.suppress instead of try/except/pass.
  • ruff format applied across repo-intel.py, gen_techdata.py, build.py — mostly line-joins and slice spacing; gen_techdata.py's curated maps expand to one entry per line (more diff-friendly when languages/frameworks change).

Notes

  • No mypy — the script is unannotated; the linter catches the real bugs without an annotation project.
  • dist/repo-intel rebuilt by the pre-commit hook; the CI staleness gate passes.

Test plan

  • make check green (Prettier, Ruff lint + format, svelte-check)
  • make build produces no dist/repo-intel diff (CI staleness gate)
  • uvx ruff@0.14.5 check . and format --check . clean

Summary by CodeRabbit

  • Chores

    • Added automated Python code quality checks (linting and formatting) to the continuous integration pipeline.
    • Introduced new development commands for running code formatting and quality checks locally.
  • Documentation

    • Updated the development documentation to include available code quality command options.

Review Change Stack

tyom added 4 commits May 23, 2026 20:02
Introduces Ruff (run via uvx, pinned) as the Python counterpart to the
existing Prettier/svelte-check tooling on the web side — dev/CI only, so
repo-intel stays stdlib-only and single-file. Adds ruff.toml, make
py-lint/py-format/py-format-check targets, and a CI lint gate.

Fixes the two real findings: build.py now names which placeholder is
missing (was an unused loop var), and collect_local uses
contextlib.suppress instead of try/except/pass. E402 is per-file-ignored
for repo-intel.py, whose HELP constant intentionally precedes imports.
Applies ruff format (Black-style, 100-col) across repo-intel.py,
gen_techdata.py, and build.py, and adds the py-format-check gate to CI
alongside the lint gate. Mostly joins lines that now fit and normalizes
slice spacing; gen_techdata.py's curated maps expand to one entry per
line, which is more diff-friendly when languages/frameworks change.
`make check` runs all static gates locally (Prettier, Ruff lint + format,
svelte-check), mirroring CI. `make format` now also runs ruff format so a
single command formats the whole repo.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57a81e33-e909-4f38-bd50-45484b157e33

📥 Commits

Reviewing files that changed from the base of the PR and between b782157 and 5380c80.

⛔ Files ignored due to path filters (1)
  • dist/repo-intel is excluded by !**/dist/**
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • Makefile
  • README.md
  • build.py
  • gen_techdata.py
  • repo-intel.py
  • ruff.toml

📝 Walkthrough

Walkthrough

This PR introduces Python code quality infrastructure via Ruff linting and formatting, refactors existing Python files for compliance, improves build error messaging, and updates developer documentation to reflect the new tooling workflow.

Changes

Python Code Quality Tooling Setup

Layer / File(s) Summary
Ruff configuration and tooling integration
ruff.toml, Makefile, .github/workflows/ci.yml
Adds Ruff configuration (line length 100, Python 3.9 target, rule selection, and per-file overrides), defines Makefile variable RUFF := uvx ruff@0.14.5 with targets py-lint, py-format, py-format-check, and composite check target; integrates Ruff checks into CI workflow via uv setup and dedicated linting/formatting verification steps.
Python code reformatting for linting compliance
gen_techdata.py, repo-intel.py
Refactors constants, function signatures, subprocess calls, and data structures to comply with Ruff formatting rules: expands URL constants and curated language/framework maps into multi-line form, condenses single-purpose assignments, reformats comprehensions and subprocess invocations, replaces try/except with contextlib.suppress, and adds contextlib import. No functional logic changes.
Build error handling improvements
build.py
Enhances placeholder substitution validation to emit specific error messages including placeholder name and expected literal, and refactors template substitution into a single chained replace() expression.
Developer documentation updates
README.md
Expands "File / Purpose" table with component-level detail (Svelte vs engine, build/bundle roles) and adds make format and make check to the local development workflow list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A toolkit grows roots so deep,
Ruff checks the code while we sleep,
Formatting flows, linting shows,
Build tests reap what this PR sows,
Quality's now part of the keep! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Ruff linting and formatting for Python sources, which aligns with the primary objectives and modifications across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ruff

Comment @coderabbitai help to get the list of available commands and usage tips.

@tyom tyom merged commit 71cc54e into main May 23, 2026
2 checks passed
@tyom tyom deleted the ruff branch May 23, 2026 19: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