ruff: Bump version and drop preview mode#977
Open
pdgendt wants to merge 13 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #977 +/- ##
==========================================
+ Coverage 86.35% 86.39% +0.04%
==========================================
Files 11 11
Lines 3532 3528 -4
==========================================
- Hits 3050 3048 -2
+ Misses 482 480 -2
|
Prepare for the upcoming Ruff 0.16 bump, whose default rule set enables several Ruff-specific rules. Annotate mutable class attributes with typing.ClassVar (RUF012), use explicit f-string conversion flags (RUF010), prefer next() over single-element slicing (RUF015), and mark unused unpacked variables (RUF059). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some flake8-simplify rules. Collapse nested if statements into a single condition (SIM102) and replace static str.split() calls with list literals (SIM905). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some flake8-comprehensions rules. Rewrite dict()/list() calls as literals (C408) and drop a redundant list() wrapper around sorted() (C413). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some flake8-return rules. Drop an unnecessary explicit "return None" (RET501). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some Perflint rules. Iterate with dict.values() where the keys are unused (PERF102). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some refurb rules. Use min() instead of sorted()[0] (FURB192) and set.discard() instead of a membership check plus remove() (FURB132). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables ISC004. Parenthesize an intentional multi-line warning message so the implicit concatenation is explicit. ISC004 also uncovered a real bug: a missing comma in _IMPORT_SELF_MANIFESTS silently concatenated the "map" self-import form into "files", so it was never exercised. Add the comma and the missing parametrize id so all three equivalent forms are tested. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some tryceratops rules. Re-raise with a bare "raise" instead of naming the caught exception (TRY201). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables BLE001. The catch-all in Init.create() is intentional: it turns any unexpected failure into a clean error message. Mark it with an explicit noqa. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some pylint warnings. run_subprocess() is a thin wrapper that forwards **kwargs, so whether to pass check= is intentionally left to the caller. Mark the subprocess.run() call with an explicit noqa (PLW1510). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables FLY002. Build the expected help text with a textwrap.dedent() block instead of joining a list of lines; it reads like the actual command output and matches the idiom already used throughout this file. This also drops the two E501 noqa directives the joined form needed. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Prepare for the Ruff 0.16 bump, whose default rule set enables some flake8-pie rules. Drop an unnecessary pass statement from a class that already has a docstring body (PIE790). Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Bump Ruff to 0.16, whose default rule set is broad and curated; extend-select now builds on it. All findings it surfaces were fixed in the preceding commits, so no new violations remain. Drop the format preview flag: the GitHub annotation output it was enabling is stable as of 0.16. Reformat the tree to the stable style (the preview-only hug-parens style is gone) and remove a leftover noqa directive for E501, which the default rule set does not enable. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
There was a problem hiding this comment.
Pull request overview
This pull request updates the repo’s Python lint/format tooling to Ruff 0.16 and removes Ruff formatter preview mode, then reformats affected sources to match the stable formatting behavior.
Changes:
- Bump Ruff to
~=0.16 in dependency groups and lockfile. - Remove
[tool.ruff.format].preview = truenow that formatter annotations are stable. - Apply mechanical refactors/formatting updates across
src/andtests/to satisfy the updated Ruff rules/format output.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates locked Ruff package from 0.14.9 to 0.16.0 and aligns dependency group specifiers to ~=0.16. |
| pyproject.toml | Bumps Ruff requirement and drops Ruff formatter preview mode; adds clarifying comment for lint rule selection. |
| src/west/manifest.py | Small cleanups (repr formatting, discard, {} literals, minor simplifications) consistent with newer Ruff rules. |
| src/west/configuration.py | Simplifies conditional structure without changing behavior. |
| src/west/commands.py | Documents intentional subprocess.run behavior and suppresses the related Ruff rule. |
| src/west/app/project.py | Adds ClassVar typing for class constants and minor literal cleanup. |
| src/west/app/main.py | Removes unused loop variable by iterating over values only. |
| src/west/app/config.py | Condenses argument validation condition without behavior change. |
| tests/test_project.py | Formatting + small mechanical refactors (list literals, dedented expected text, unused variable rename). |
| tests/test_project_caching.py | Minor improvement to pick deterministic entries via min() and formatting updates. |
| tests/test_manifest.py | Formatting changes and expands parametrization IDs to match the additional manifest form. |
| tests/test_extension_commands.py | Uses next(...) for clearer single-item selection; formatting updates. |
| tests/test_config.py | Minor simplification (remove redundant list(sorted(...))) and formatting updates. |
| tests/conftest.py | Formatting updates and uses bare raise to preserve tracebacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ruff 0.16 broadens the default rule set that extend-select builds on, fix issues before the actual bump.
See individual commits for details.
Preview mode was only enabled to get GitHub annotation output from the formatter, which is stable as of Ruff 0.16. Drop it and reformat the files that relied on the preview-only hug-parens style.
Sadly this does format some (mostly test) files, if not desired, the preview mode could be kept.