Skip to content

boot-utils: Enable and fix several Ruff rules#132

Merged
msfjarvis merged 8 commits intoClangBuiltLinux:mainfrom
nathanchance:update-ruff-toml
Apr 13, 2026
Merged

boot-utils: Enable and fix several Ruff rules#132
msfjarvis merged 8 commits intoClangBuiltLinux:mainfrom
nathanchance:update-ruff-toml

Conversation

@nathanchance
Copy link
Copy Markdown
Member

See the individual commits for the full details.

This was done in tc-build but not this repo, where it actually improves
readability quite a bit.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As suggested by the refurb rules from ruff:

  FURB167 [*] Use of regular expression alias `re.M`
     --> boot-qemu.py:140:93
      |
  138 |         strings_stdout = strings.stdout.decode(encoding='utf-8', errors='ignore')
  139 |
  140 |         if not (match := re.search(r'^Linux version (\d+\.\d+\.\d+)', strings_stdout, flags=re.M)):
      |                                                                                             ^^^^
  141 |             raise RuntimeError(f"Could not find Linux version in {self.kernel}?")
      |
  help: Replace with `re.MULTILINE`

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As pointed out by the refurb rules in ruff.toml:

  FURB171 Membership test against single-item container
     --> boot-qemu.py:130:12
      |
  129 |         utils.check_cmd(decomp_prog)
  130 |         if decomp_prog in ('gzip',):
      |            ^^^^^^^^^^^^^^^^^^^^^^^^
  131 |             decomp_cmd = [decomp_prog, '-c', '-d', self.kernel]
  132 |         else:
      |
  help: Convert to equality test

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
There are no instances of these currently but they all seem like
relatively safe additions (even if DTZ may never get triggered since
this project does not use datetime).

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@msfjarvis msfjarvis merged commit 208f703 into ClangBuiltLinux:main Apr 13, 2026
6 checks passed
@nathanchance nathanchance deleted the update-ruff-toml branch April 14, 2026 00:04
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