Skip to content

ruff: Bump version and drop preview mode#977

Open
pdgendt wants to merge 13 commits into
zephyrproject-rtos:mainfrom
pdgendt:ruff-bump
Open

ruff: Bump version and drop preview mode#977
pdgendt wants to merge 13 commits into
zephyrproject-rtos:mainfrom
pdgendt:ruff-bump

Conversation

@pdgendt

@pdgendt pdgendt commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

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.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.39%. Comparing base (ff022a1) to head (be1fd0c).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/west/app/project.py 71.42% 2 Missing ⚠️
src/west/configuration.py 50.00% 1 Missing ⚠️
src/west/manifest.py 87.50% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/west/app/config.py 95.32% <100.00%> (-0.05%) ⬇️
src/west/app/main.py 79.15% <100.00%> (ø)
src/west/commands.py 95.63% <100.00%> (ø)
src/west/configuration.py 86.46% <50.00%> (-0.04%) ⬇️
src/west/manifest.py 95.34% <87.50%> (+0.17%) ⬆️
src/west/app/project.py 82.03% <71.42%> (+0.01%) ⬆️

pdgendt added 10 commits July 24, 2026 10:49
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>
pdgendt added 3 commits July 24, 2026 11:34
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>
@pdgendt
pdgendt marked this pull request as ready for review July 24, 2026 09:41
@kartben
kartben requested a review from Copilot July 24, 2026 14:44

Copilot AI 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.

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 = true now that formatter annotations are stable.
  • Apply mechanical refactors/formatting updates across src/ and tests/ 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.

@pdgendt pdgendt self-assigned this Jul 24, 2026
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