Skip to content

Replace linters and formatters with ruff#338

Merged
mulkieran merged 2 commits into
stratis-storage:masterfrom
mulkieran:replace-linters-and-formatters-with-ruff
Apr 29, 2026
Merged

Replace linters and formatters with ruff#338
mulkieran merged 2 commits into
stratis-storage:masterfrom
mulkieran:replace-linters-and-formatters-with-ruff

Conversation

@mulkieran

@mulkieran mulkieran commented Apr 29, 2026

Copy link
Copy Markdown
Member

Related stratis-storage/project#64

Summary by CodeRabbit

  • Chores
    • Migrated build and development tooling from multiple linters and formatters (pylint, black, isort) to a unified Ruff tool for improved development efficiency.
    • Updated CI/CD pipeline to use Ruff for consistent code linting and formatting checks across all builds.
    • Updated project configuration to support Ruff with Python 3.12 target version and standardized formatting rules.

Signed-off-by: mulhern <amulhern@redhat.com>
@mulkieran mulkieran self-assigned this Apr 29, 2026
@mulkieran mulkieran moved this to In Progress in 2026April Apr 29, 2026
@mulkieran

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Walkthrough

This pull request migrates the codebase from multiple Python linting and formatting tools (pylint, black, isort) to a unified ruff configuration. CI workflows and build configuration files are updated to use ruff, pylint suppression comments are removed throughout the codebase, and tool-specific configuration files are deleted or replaced. Formatting adjustments and minor logic restructuring in select modules accompany the migration.

Changes

Cohort / File(s) Summary
CI Configuration
.github/workflows/main.yml
CI lint/format jobs updated to invoke ruff instead of pylint, black, and isort; PYTHONPATH=./src environment variable removed from lint task.
Build & Tool Configuration
Makefile, .isort.cfg, pyproject.toml
Makefile targets (lint, fmt, fmt-travis) replaced to use ruff check and ruff format commands; .isort.cfg deleted; pyproject.toml adds ruff configuration with target Python 3.12, line length 88, and import sorting rules.
Script Code
scripts/monitor_dbus_signals.py, scripts/monitor_metadata.py
Pylint suppression comments removed; multi-line constructor signatures simplified; minor string quoting style adjustments for consistency.
Test Certificate Files
stratis_cli_cert.py, stratisd_cert.py
Pylint suppress directives (too-many-public-methods, too-many-lines) removed from class and module declarations; class definition formatting simplified; dd command string quoting adjusted.
Test Infrastructure
test_harness.py, testlib/dbus.py, testlib/infra.py, testlib/utils.py
Pylint disable comments removed across class declarations and function signatures; testlib/infra.py refactors error-message string formatting and restructures control flow (elif replaces nested else block); blank line inserted in testlib/utils.py between docstring and imports; specific return-code comparisons annotated with # noqa PLR2004.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.53% 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 accurately summarizes the main objective of the changeset: replacing pylint, black, and isort with ruff across the repository's configuration, CI, and 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 unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
pyproject.toml (1)

5-6: Use extend-select = ["PL"] to add Pylint rules while preserving default linting.

At Line 6, select = ["PL"] replaces Ruff's default rule set (E4, E7, E9, F) with only Pylint rules, narrowing lint coverage. Unless this narrowing is intentional, use extend-select to add Pylint rules while keeping the defaults.

Suggested config adjustment
 [tool.ruff.lint]
-select = ["PL"]
+extend-select = ["PL"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` around lines 5 - 6, The current Ruff config under
[tool.ruff.lint] uses select = ["PL"], which replaces Ruff's default rule set;
change this to extend-select = ["PL"] so Pylint rules are added without losing
defaults. Locate the [tool.ruff.lint] section and replace the select key with
extend-select (or add extend-select alongside existing defaults) to preserve
default rule groups (E4, E7, E9, F) while enabling the "PL" rules.
testlib/infra.py (1)

613-620: Fix Ruff noqa directive syntax to use colon for scoped suppression.

Lines 613 and 620 use # noqa PLR2004 (space separator), which is the blanket form. Use # noqa: PLR2004 (with colon) to keep suppression precise and scoped to the specific code violations.

Proposed fix
-            if self.trace.returncode == 3:  # noqa PLR2004
+            if self.trace.returncode == 3:  # noqa: PLR2004
...
-            if self.trace.returncode == 4:  # noqa PLR2004
+            if self.trace.returncode == 4:  # noqa: PLR2004
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testlib/infra.py` around lines 613 - 620, Update the inline Ruff suppression
comments on the return-code checks to use the scoped form with a colon; locate
the two occurrences where the code checks self.trace.returncode (the branches
checking == 3 and == 4) and change "# noqa PLR2004" to "# noqa: PLR2004" so the
suppression is properly scoped to those lines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/monitor_dbus_signals.py`:
- Around line 419-420: The except blocks currently append raw exception objects
to _CALLBACK_ERRORS (e.g., "except Exception as exc:
_CALLBACK_ERRORS.append(exc)"); change these to append a string representation
(preferably the full traceback) so later reporting/joining is reliable — for
example use traceback.format_exc() or str(exc) and append that string to
_CALLBACK_ERRORS; update all three occurrences that append exc (the except
blocks that reference exc at the three noted spots) and add an import for
traceback if you choose format_exc().

In `@test_harness.py`:
- Around line 45-46: In _LogBlockdev.__str__, replace the bare "except:" that
returns `f"could not gather output of {self.cmd}"` with "except Exception:" so
only regular exceptions are caught (allowing KeyboardInterrupt/SystemExit to
propagate); update the except clause in the __str__ method to use "except
Exception:" and keep the existing return behavior and message using self.cmd.

---

Nitpick comments:
In `@pyproject.toml`:
- Around line 5-6: The current Ruff config under [tool.ruff.lint] uses select =
["PL"], which replaces Ruff's default rule set; change this to extend-select =
["PL"] so Pylint rules are added without losing defaults. Locate the
[tool.ruff.lint] section and replace the select key with extend-select (or add
extend-select alongside existing defaults) to preserve default rule groups (E4,
E7, E9, F) while enabling the "PL" rules.

In `@testlib/infra.py`:
- Around line 613-620: Update the inline Ruff suppression comments on the
return-code checks to use the scoped form with a colon; locate the two
occurrences where the code checks self.trace.returncode (the branches checking
== 3 and == 4) and change "# noqa PLR2004" to "# noqa: PLR2004" so the
suppression is properly scoped to those lines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4003422-25d8-4dcb-9ae7-1c315b9b3fd4

📥 Commits

Reviewing files that changed from the base of the PR and between 4136e93 and 5e3b979.

📒 Files selected for processing (12)
  • .github/workflows/main.yml
  • .isort.cfg
  • Makefile
  • pyproject.toml
  • scripts/monitor_dbus_signals.py
  • scripts/monitor_metadata.py
  • stratis_cli_cert.py
  • stratisd_cert.py
  • test_harness.py
  • testlib/dbus.py
  • testlib/infra.py
  • testlib/utils.py
💤 Files with no reviewable changes (1)
  • .isort.cfg

Comment thread scripts/monitor_dbus_signals.py
Comment thread test_harness.py
@mulkieran
mulkieran marked this pull request as ready for review April 29, 2026 14:24
Signed-off-by: mulhern <amulhern@redhat.com>
@mulkieran
mulkieran force-pushed the replace-linters-and-formatters-with-ruff branch from 5e3b979 to 0ebda4b Compare April 29, 2026 14:27
@mulkieran
mulkieran merged commit 2c43ed8 into stratis-storage:master Apr 29, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in 2026April Apr 29, 2026
@mulkieran
mulkieran deleted the replace-linters-and-formatters-with-ruff branch April 29, 2026 17:53
@mulkieran mulkieran added this to the v3.9.1 milestone Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants