Skip to content

Commit a0b1cca

Browse files
committed
scripts: west_commands: build_helpers: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
1 parent fcaa2bc commit a0b1cca

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

.ruff-excludes.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,6 @@
10731073
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
10741074
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import
10751075
]
1076-
"./scripts/west_commands/build_helpers.py" = [
1077-
"E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
1078-
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
1079-
"UP032", # https://docs.astral.sh/ruff/rules/f-string
1080-
]
10811076
"./scripts/west_commands/debug.py" = [
10821077
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
10831078
"UP008", # https://docs.astral.sh/ruff/rules/super-call-with-parameters

scripts/west_commands/build_helpers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
See build.py for the build command itself.
1111
'''
1212

13-
import zcmake
1413
import os
1514
import sys
1615
from pathlib import Path
16+
17+
import zcmake
1718
from west import log
1819
from west.configuration import config
1920
from west.util import escapes_directory
@@ -22,19 +23,19 @@
2223
# twister also uses the implementation
2324
script_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
2425
sys.path.insert(0, os.path.join(script_dir, "pylib/build_helpers/"))
25-
from domains import Domains
26+
from domains import Domains # noqa: E402
2627

2728
DEFAULT_BUILD_DIR = 'build'
2829
'''Name of the default Zephyr build directory.'''
2930

3031
DEFAULT_CMAKE_GENERATOR = 'Ninja'
3132
'''Name of the default CMake generator.'''
3233

33-
FIND_BUILD_DIR_DESCRIPTION = '''\
34-
If the build directory is not given, the default is {}/ unless the
34+
FIND_BUILD_DIR_DESCRIPTION = f'''\
35+
If the build directory is not given, the default is {DEFAULT_BUILD_DIR}/ unless the
3536
build.dir-fmt configuration variable is set. The current directory is
3637
checked after that. If either is a Zephyr build directory, it is used.
37-
'''.format(DEFAULT_BUILD_DIR)
38+
'''
3839

3940
def _resolve_build_dir(fmt, guess, cwd, **kwargs):
4041
# Remove any None values, we do not want 'None' as a string
@@ -100,14 +101,14 @@ def find_build_dir(dir, guess=False, **kwargs):
100101
cwd = os.getcwd()
101102
default = config.get('build', 'dir-fmt', fallback=DEFAULT_BUILD_DIR)
102103
default = _resolve_build_dir(default, guess, cwd, **kwargs)
103-
log.dbg('config dir-fmt: {}'.format(default), level=log.VERBOSE_EXTREME)
104+
log.dbg(f'config dir-fmt: {default}', level=log.VERBOSE_EXTREME)
104105
if default and is_zephyr_build(default):
105106
build_dir = default
106107
elif is_zephyr_build(cwd):
107108
build_dir = cwd
108109
else:
109110
build_dir = default
110-
log.dbg('build dir: {}'.format(build_dir), level=log.VERBOSE_EXTREME)
111+
log.dbg(f'build dir: {build_dir}', level=log.VERBOSE_EXTREME)
111112
if build_dir:
112113
return os.path.abspath(build_dir)
113114
else:

0 commit comments

Comments
 (0)