Replace linters and formatters with ruff#338
Replace linters and formatters with ruff#338mulkieran merged 2 commits intostratis-storage:masterfrom
Conversation
Signed-off-by: mulhern <amulhern@redhat.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
pyproject.toml (1)
5-6: Useextend-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, useextend-selectto 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
📒 Files selected for processing (12)
.github/workflows/main.yml.isort.cfgMakefilepyproject.tomlscripts/monitor_dbus_signals.pyscripts/monitor_metadata.pystratis_cli_cert.pystratisd_cert.pytest_harness.pytestlib/dbus.pytestlib/infra.pytestlib/utils.py
💤 Files with no reviewable changes (1)
- .isort.cfg
Signed-off-by: mulhern <amulhern@redhat.com>
5e3b979 to
0ebda4b
Compare
Related stratis-storage/project#64
Summary by CodeRabbit