Skip to content

tc-build: Enable more Ruff lints#329

Merged
msfjarvis merged 6 commits intoClangBuiltLinux:mainfrom
nathanchance:more-ruff-lints
Apr 13, 2026
Merged

tc-build: Enable more Ruff lints#329
msfjarvis merged 6 commits intoClangBuiltLinux:mainfrom
nathanchance:more-ruff-lints

Conversation

@nathanchance
Copy link
Copy Markdown
Member

See the individual commits for the full details.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As suggested by the refurb lints in Ruff:

  FURB167 [*] Use of regular expression alias `re.M`
     --> tc_build/llvm.py:585:94
      |
  583 |             tool
  584 |             for cmakelists_txt in cmakelists_txts
  585 |             if (match := re.search(r"^add_(?:clang|llvm)_tool\((.*)$", cmakelists_txt, flags=re.M))
      |                                                                                              ^^^^
  586 |             and (tool := match.groups()[0]) not in skip_tools
  587 |         ]
      |
  help: Replace with `re.MULTILINE`

  FURB167 [*] Use of regular expression alias `re.M`
    --> tc_build/source.py:45:85
     |
  43 |             if not (
  44 |                 match := re.search(
  45 |                     rf"([0-9a-f]+)\s+{self.remote_tarball_name}$", checksums, flags=re.M
     |                                                                                     ^^^^
  46 |                 )
  47 |             ):
     |
  help: Replace with `re.MULTILINE`

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As suggested by the refurb Ruff lints:

  FURB110 [*] Replace ternary `if` expression with `or` operator
    --> tc_build/source.py:93:31
     |
  91 | class SourceManager:
  92 |     def __init__(self, location: Optional[Path] = None) -> None:
  93 |         self.location: Path = location if location else tc_build.utils.UNINIT_PATH
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  94 |         self.tarball = Tarball()
     |
  help: Replace with `or` operator

  FURB110 [*] Replace ternary `if` expression with `or` operator
    --> tc_build/utils.py:75:23
     |
  73 |     # on.
  74 |     ldd_out = subprocess.run(['ldd', '--version'], capture_output=True, check=False, text=True)
  75 |     return 'musl' in (ldd_out.stderr if ldd_out.stderr else ldd_out.stdout)
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
  help: Replace with `or` operator

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
TRY003 fires too often in our code currently and its value is fairly
low.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
There are no instances of warnings in these categories currently.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance nathanchance requested a review from msfjarvis as a code owner April 13, 2026 23:39
@msfjarvis msfjarvis merged commit a2bc349 into ClangBuiltLinux:main Apr 13, 2026
8 checks passed
@msfjarvis msfjarvis deleted the more-ruff-lints branch April 13, 2026 23:48
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