Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ jobs:
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
with:
version: "0.14.9"
args: "--version"

- run: ruff check --diff

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/pr-auto-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ jobs:
echo "Running cargo fmt --all on PR #${{ github.event.pull_request.number }}"
cargo fmt --all

- name: Install ruff
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
with:
version: "0.14.9"
args: "--version"

- run: ruff format
- run: ruff check --select I --fix

Comment on lines +48 to +50
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

ruff import sorting affects formatting stability ruff format after ruff check I fix

💡 Result:

Short answer: Ruff separates concerns — import sorting is a lint fix (rule I001) and the formatter intentionally does not reorder imports. Run the linter fixer first, then the formatter:

  • ruff check --select I --fix .
  • ruff format .

This ensures imports are grouped/sorted (I rules) and then the file is formatted. You can automate via a pre-commit hook or add select/settings in ruff.toml. [1][2][3]

Sources:

  • Ruff formatter docs (notes import-sorting is done by the linter). [1]
  • unsorted-imports (I001) rule (describes de-dup/group/sort behavior). [2]
  • Community / how-to references (Stack Overflow / guides showing the two-step sequence). [3]

Swap the order: run ruff check --select I --fix before ruff format for stable formatting.

Ruff separates import sorting (a linter concern) from formatting. Running import fixes after formatting can undo formatting changes, since the formatter does not reorder imports. The recommended sequence is ruff check --select I --fix . followed by ruff format ..

🤖 Prompt for AI Agents
.github/workflows/pr-auto-commit.yaml lines 48-50: the workflow runs ruff format
before running ruff check --select I --fix which can cause import-fix changes to
be overwritten; swap the commands so ruff check --select I --fix (ideally with a
path like `.`) runs first to apply import sorting, then run ruff format (also
with `.`) to produce stable formatting; update the two run steps accordingly and
ensure both commands target the repository path.

- name: Configure git
run: |
git config user.name "github-actions[bot]"
Expand Down
Loading