Skip to content

Commit 0c18197

Browse files
pdgendtkartben
authored andcommitted
scripts: west_commands: bindesc: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
1 parent 5f7fbb6 commit 0c18197

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
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/bindesc.py" = [
1077-
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
1078-
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
1079-
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance
1080-
]
10811076
"./scripts/west_commands/blobs.py" = [
10821077
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
10831078
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports

scripts/west_commands/bindesc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
from textwrap import dedent
65
import struct
6+
from textwrap import dedent
77

88
from west.commands import WestCommand
99

10-
1110
try:
1211
from elftools.elf.elffile import ELFFile
1312
from intelhex import IntelHex
@@ -28,7 +27,7 @@ def convert_from_uf2(cmd, buf):
2827
block = buf[ptr:ptr + 512]
2928
hd = struct.unpack(b'<IIIIIIII', block[0:32])
3029
if hd[0] != UF2_MAGIC_START0 or hd[1] != UF2_MAGIC_START1:
31-
cmd.inf('Skipping block at ' + ptr + '; bad magic')
30+
cmd.inf(f'Skipping block at {ptr}; bad magic')
3231
continue
3332
if hd[2] & 1:
3433
# NO-flash flag set; skip block
@@ -124,7 +123,8 @@ def do_add_parser(self, parser_adder):
124123
search_parser = subparsers.add_parser('search', help='Search for a specific descriptor')
125124
search_parser.add_argument('descriptor', type=str, help='Descriptor name')
126125
search_parser.add_argument('file', type=str, help='Executable file')
127-
search_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS, help='File type')
126+
search_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS,
127+
help='File type')
128128
search_parser.add_argument('-b', '--big-endian', action='store_true',
129129
help='Target CPU is big endian')
130130
search_parser.set_defaults(subcmd='search', big_endian=False)
@@ -144,7 +144,8 @@ def do_add_parser(self, parser_adder):
144144
list_parser = subparsers.add_parser('list', help='List all known descriptors')
145145
list_parser.set_defaults(subcmd='list', big_endian=False)
146146

147-
get_offset_parser = subparsers.add_parser('get_offset', help='Get the offset of the descriptors')
147+
get_offset_parser = subparsers.add_parser('get_offset',
148+
help='Get the offset of the descriptors')
148149
get_offset_parser.add_argument('file', type=str, help='Executable file')
149150
get_offset_parser.add_argument('--file-type', type=str, choices=self.EXTENSIONS,
150151
help='File type')
@@ -329,5 +330,5 @@ def align(x, alignment):
329330
def bindesc_repr(value):
330331
if isinstance(value, str):
331332
return f'"{value}"'
332-
if isinstance(value, (int, bytes)):
333+
if isinstance(value, int | bytes):
333334
return f'{value}'

0 commit comments

Comments
 (0)