Skip to content

pre-commit#827

Merged
podkidyshev merged 5 commits intomainfrom
ipod/pre-commit
Mar 10, 2026
Merged

pre-commit#827
podkidyshev merged 5 commits intomainfrom
ipod/pre-commit

Conversation

@podkidyshev
Copy link
Contributor

@podkidyshev podkidyshev commented Mar 10, 2026

Summary

Automatically run linters on commit. They are optimized (mostly) to run only against the diff of your commit, not entire repo

Test Plan

  • Automated CI

Additional Notes

Failure in CI example (in case one committed without running pre-commit locally)

image

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

This PR centralizes CI linting into a single pre-commit step, adds a pre-commit config and dev dependency, updates CONTRIBUTING.md with pre-commit instructions, and applies numerous whitespace/EOF formatting fixes across docs and scripts.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/ci.yml
Replaces multiple tool-specific lint steps with one "Run linting via pre-commit" step that runs pre-commit and shows diffs on failure.
Pre-commit & packaging
.pre-commit-config.yaml, .gitignore, pyproject.toml
Adds .pre-commit-config.yaml with hooks (ruff, ruff-format, pyright, vulture, import-linter, taplo, check-* hooks), un-ignores the config file, and adds pre-commit~=4.0 to dev extras.
Contributor docs
CONTRIBUTING.md
Replaces previous linter instructions with steps to install and run pre-commit locally.
Docs whitespace fixes
doc/index.rst, doc/DEV.rst, doc/reporting.rst, doc/workloads/aiconfigurator.rst, doc/workloads/ddlb.rst, doc/workloads/deepep.rst, doc/workloads/megatron_bridge.rst, doc/workloads/nemo_launcher.rst, .github/workflows/docs.yml
Removed/adjusted trailing blank lines, no-newline markers, and minor formatting-only edits.
EOF & templates/scripts
conf/common/test_scenario/ucc_generator_file.txt, greptile.json, src/cloudai/systems/slurm/slurm-metadata.sh, src/cloudai/util/base-report.jinja2, src/cloudai/util/nixl_report_template.jinja2, src/cloudai/workloads/ai_dynamo/ai_dynamo.sh
Normalized trailing newlines, removed trailing whitespace, and a tiny whitespace tweak in a shell variable; no logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through code with tiny paws,
Herded linters into one neat cause,
Trimmed stray spaces, added a line,
Hooks now hum in tidy design,
A happy rabbit, linting applause! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'pre-commit' is overly vague and generic, referring only to the tool name without describing the actual change or its purpose. Use a more descriptive title that explains the main change, such as 'Consolidate linting to pre-commit hooks' or 'Add automated pre-commit linters to CI'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the purpose (automatically run linters on commit), the approach (optimized to run against diffs), and includes a test plan and CI failure example.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ipod/pre-commit

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

@podkidyshev podkidyshev marked this pull request as ready for review March 10, 2026 12:12
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR introduces a .pre-commit-config.yaml to automate linting on every local commit and consolidates the CI linting job into a single pre-commit run --all-files step, replacing the previous individually-defined ruff, pyright, vulture, import-linter, and taplo CI steps. It also adds pre-commit~=4.0 as a dev dependency, moves the vulture paths config from CLI arguments to pyproject.toml, and fixes missing newlines at end of file across several files.

Key changes:

  • .pre-commit-config.yaml added with hooks for pre-commit-hooks, pyright-python, ruff, vulture, import-linter, and a local taplo hook
  • CI lint job simplified to pre-commit run --all-files --show-diff-on-failure
  • pyproject.toml: pre-commit~=4.0 added to dev extras; paths = ["src/", "tests/"] moved into [tool.vulture] so the hook picks it up without CLI arguments
  • .gitignore updated with !.pre-commit-config.yaml to prevent the new config from being ignored by the existing .* wildcard
  • Numerous files fixed for missing newlines at end of file and trailing whitespace

Issues found:

  • The import-linter hook is missing language: system. All other Python-based hooks (pyright, ruff-check, ruff-format, vulture) set language: system to use the host environment where cloudai is installed. Without this, pre-commit creates an isolated virtualenv for import-linter that does not contain the project, causing lint-imports to fail to resolve the cloudai package (the original CI step explicitly set PYTHONPATH=src for this reason).
  • minimum_pre_commit_version: "3.7.0" in the config is inconsistent with pre-commit~=4.0 in pyproject.toml; consider raising the minimum to "4.0.0" for clarity.

Confidence Score: 3/5

  • Safe to merge after fixing the import-linter hook's missing language: system setting, which will otherwise cause the hook to fail in isolated CI environments.
  • The overall approach is sound and the CI simplification is clean. The one blocking issue is the import-linter hook lacking language: system, which will cause it to run in an isolated venv without the project installed and fail to resolve cloudai imports — breaking the very linting pipeline this PR is meant to establish. The version inconsistency between minimum_pre_commit_version and the dev dependency is a minor cosmetic issue.
  • .pre-commit-config.yaml — the import-linter hook needs language: system added.

Important Files Changed

Filename Overview
.pre-commit-config.yaml New pre-commit configuration introducing hooks for standard checks, pyright, ruff, vulture, import-linter, and taplo; the import-linter hook is missing language: system which will cause it to run in an isolated venv without the project installed, and the minimum_pre_commit_version is inconsistent with the dev dependency pin.
.github/workflows/ci.yml Replaces individual linter steps (ruff, pyright, vulture, import-linter, taplo) with a single pre-commit run --all-files --show-diff-on-failure step; straightforward and correct.
pyproject.toml Adds pre-commit~=4.0 to dev dependencies and moves vulture paths config from CLI arguments to [tool.vulture] table so the pre-commit hook picks it up automatically; both changes are correct.
.gitignore Adds !.pre-commit-config.yaml negation rule so the new config file is not hidden by the existing .* wildcard; correct and necessary.
CONTRIBUTING.md Updates developer instructions to reference the new pre-commit workflow instead of the old manual linter commands; clear and accurate.
.github/workflows/docs.yml Adds missing newline at end of file; trivial fix.
uv.lock Lock file updated to include pre-commit and its transitive dependencies (cfgv, identify, distlib, platformdirs, virtualenv, python-discovery); expected consequence of adding pre-commit to dev extras.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant PC as pre-commit
    participant Hooks as Hooks (ruff, pyright, vulture, import-linter, taplo)
    participant CI as GitHub Actions CI

    Dev->>PC: git commit
    PC->>Hooks: run hooks on staged files
    Hooks-->>PC: pass / fail
    PC-->>Dev: commit allowed or blocked with diff

    note over CI: On pull_request trigger
    CI->>CI: pip install '.[dev,docs]'
    CI->>PC: pre-commit run --all-files --show-diff-on-failure
    PC->>Hooks: run all hooks on all files
    Hooks-->>PC: results
    PC-->>CI: pass or show diff and fail
Loading

Comments Outside Diff (2)

  1. .pre-commit-config.yaml, line 44-47 (link)

    import-linter hook missing language: system

    All other Python-based hooks in this file (pyright, ruff-check, ruff-format, vulture) explicitly set language: system so they run using the host Python environment where the project is installed. The import-linter hook omits this setting, so pre-commit will create an isolated virtualenv that only contains import-linter itself — without cloudai installed or PYTHONPATH=src set.

    The original CI step was:

    PYTHONPATH=src lint-imports

    This shows that import-linter needs to be able to resolve the cloudai package. Without language: system, lint-imports will fail to find cloudai and the hook will error out.

  2. .pre-commit-config.yaml, line 1 (link)

    Inconsistency between minimum_pre_commit_version and dev dependency

    minimum_pre_commit_version: "3.7.0" indicates the config is compatible with pre-commit ≥ 3.7, but pyproject.toml pins the dev dependency to pre-commit~=4.0 (i.e., ≥ 4.0, < 5.0). A developer installing the dev extras will get pre-commit 4.x, while the config file claims to support 3.7+. Consider aligning these by raising the minimum version to "4.0.0" to match what is actually installed:

Last reviewed commit: 0da426a

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.pre-commit-config.yaml:
- Around line 34-56: Hooks pyright, vulture, lint-imports, and taplo-fmt are
configured with pass_filenames: false and no files/types filters so they always
run against the whole repo or hardcoded paths; change their configs to scope to
relevant changed files by either setting pass_filenames: true (so the hook
receives the changed filenames) or adding precise files/types globs for each
hook (e.g. Python src/** tests/** for pyright/vulture/lint-imports and toml/glob
for taplo-fmt) and remove hardcoded repo-wide paths; update the entries for the
id values pyright, vulture, lint-imports, and taplo-fmt accordingly so the hooks
only run on matching file changes.

In `@CONTRIBUTING.md`:
- Around line 27-33: Update the CONTRIBUTING.md text that currently enumerates
specific linters to instead point contributors to use the pre-commit
configuration as the canonical source: replace the sentence that lists `ruff
check`, `pyright`, etc. with wording that says "Ensure your code passes the
pre-commit hooks defined in .pre-commit-config.yaml" (and keep the existing
pre-commit install/run commands). Reference .pre-commit-config.yaml as the
source of truth and remove the hard-coded tool list so future hook changes in
ci.yml or .pre-commit-config.yaml stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47e9e874-eeb8-45dc-bbd9-e14af3468341

📥 Commits

Reviewing files that changed from the base of the PR and between a93a0e7 and ee0ae38.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • .github/workflows/ci.yml
  • .github/workflows/docs.yml
  • .gitignore
  • .pre-commit-config.yaml
  • CONTRIBUTING.md
  • conf/common/test_scenario/ucc_generator_file.txt
  • doc/DEV.rst
  • doc/index.rst
  • doc/reporting.rst
  • doc/workloads/aiconfigurator.rst
  • doc/workloads/ddlb.rst
  • doc/workloads/deepep.rst
  • doc/workloads/megatron_bridge.rst
  • doc/workloads/nemo_launcher.rst
  • greptile.json
  • pyproject.toml
  • src/cloudai/systems/slurm/slurm-metadata.sh
  • src/cloudai/util/base-report.jinja2
  • src/cloudai/util/nixl_report_template.jinja2
  • src/cloudai/workloads/ai_dynamo/ai_dynamo.sh
💤 Files with no reviewable changes (6)
  • doc/workloads/aiconfigurator.rst
  • doc/workloads/ddlb.rst
  • doc/index.rst
  • doc/reporting.rst
  • doc/DEV.rst
  • doc/workloads/deepep.rst

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
.pre-commit-config.yaml (1)

52-55: 🧹 Nitpick | 🔵 Trivial

Add files filter and ensure trailing newline.

The taplo-fmt hook should include a files filter to only trigger on TOML file changes, avoiding unnecessary runs on unrelated commits. Also, the file appears to be missing a trailing newline.

♻️ Proposed fix
       - id: taplo-fmt
         name: taplo
         entry: taplo fmt --check --diff
         language: system
+        files: \.toml$
+
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 52 - 55, Update the taplo-fmt hook
block (id: taplo-fmt, name: taplo, entry: taplo fmt --check --diff) to include a
files filter that restricts the hook to TOML files (e.g., add files:
'\\.toml$'), and ensure the .pre-commit-config.yaml file ends with a trailing
newline so the file terminates with a newline character.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.pre-commit-config.yaml:
- Line 33: The YAML linter is failing due to extra spaces inside the
square-bracket list for the pre-commit hook args; locate the args entry shown as
args: [ --fix ] and remove the inner spacing so the list is compact (args:
[--fix]) to conform to YAMLlint/bracket-spacing rules.

In `@CONTRIBUTING.md`:
- Around line 28-34: The fenced bash code block containing the three commands
starting with "uv sync --extra dev" needs a blank line inserted immediately
before the opening ```bash and another blank line immediately after the closing
``` so the block is surrounded by empty lines per MD031; update the section in
CONTRIBUTING.md where that block appears (the block with "uv sync --extra dev",
"uv run pre-commit install", "uv run pre-commit run --all-files") to include one
blank line above the opening fence and one blank line below the closing fence.

---

Duplicate comments:
In @.pre-commit-config.yaml:
- Around line 52-55: Update the taplo-fmt hook block (id: taplo-fmt, name:
taplo, entry: taplo fmt --check --diff) to include a files filter that restricts
the hook to TOML files (e.g., add files: '\\.toml$'), and ensure the
.pre-commit-config.yaml file ends with a trailing newline so the file terminates
with a newline character.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c046f3bb-6f17-4e26-9cf2-b81eca1853cb

📥 Commits

Reviewing files that changed from the base of the PR and between ee0ae38 and ccea3eb.

📒 Files selected for processing (3)
  • .pre-commit-config.yaml
  • CONTRIBUTING.md
  • pyproject.toml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
CONTRIBUTING.md (1)

28-33: ⚠️ Potential issue | 🟡 Minor

Add a blank line before the fenced code block.

The bash block still violates MD031 because the opening fence immediately follows the list item text. Insert an empty line before ```bash so the block is surrounded by blank lines consistently.

📝 Proposed fix
   - Ensure your changes pass the pre-commit checks defined in `.pre-commit-config.yaml`.
   - Install and run pre-commit hooks locally:
+
     ```bash
     uv sync --extra dev
     uv run pre-commit install
     uv run pre-commit run --all-files
     ```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTRIBUTING.md` around lines 28 - 33, The fenced bash code block after the
list item in CONTRIBUTING.md (the block starting with ```bash) violates MD031
because the opening fence immediately follows the list text; fix this by
inserting a blank line between the list item text and the opening ```bash fence
(and ensure there's a blank line after the closing fence as well so the code
block is surrounded by blank lines).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@CONTRIBUTING.md`:
- Around line 28-33: The fenced bash code block after the list item in
CONTRIBUTING.md (the block starting with ```bash) violates MD031 because the
opening fence immediately follows the list text; fix this by inserting a blank
line between the list item text and the opening ```bash fence (and ensure
there's a blank line after the closing fence as well so the code block is
surrounded by blank lines).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 365c0acb-a4cc-4628-a974-9fdeed2674b2

📥 Commits

Reviewing files that changed from the base of the PR and between ccea3eb and 0da426a.

📒 Files selected for processing (1)
  • CONTRIBUTING.md

@podkidyshev podkidyshev merged commit 5773e2b into main Mar 10, 2026
5 checks passed
@podkidyshev podkidyshev deleted the ipod/pre-commit branch March 10, 2026 13:47
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.

2 participants