Skip to content

Commit 7be6b1f

Browse files
Copilotdobairoland
andcommitted
Complete pyupgrade implementation: fix all UP031 and line length issues
Co-authored-by: dobairoland <[email protected]>
1 parent 3095646 commit 7be6b1f

File tree

25 files changed

+139
-64
lines changed

25 files changed

+139
-64
lines changed

espefuse/efuse/base_fields.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ def print_block(self, bit_string, comment, debug=False):
264264
if self.parent.debug or debug:
265265
bit_string.pos = 0
266266
log.print(
267-
"{:<15s} ({:<16s}) [{:>2d}] {}:".format(self.name, " ".join(self.alias)[:16], self.id, comment),
267+
"{:<15s} ({:<16s}) [{:>2d}] {}:".format(
268+
self.name, " ".join(self.alias)[:16], self.id, comment
269+
),
268270
" ".join(
269271
[
270272
"{:08x}".format(word)
@@ -284,7 +286,9 @@ def check_wr_data(self):
284286
return False
285287
if len(wr_data.bytes) != len(self.bitarray.bytes):
286288
raise esptool.FatalError(
287-
"Data does not fit: the block{} size is {} bytes, data is {} bytes".format(self.id, len(self.bitarray.bytes), len(wr_data.bytes))
289+
"Data does not fit: block{} size {} bytes, data {} bytes".format(
290+
self.id, len(self.bitarray.bytes), len(wr_data.bytes)
291+
)
288292
)
289293
self.check_wr_rd_protect()
290294

@@ -672,7 +676,9 @@ def burn_block(block, postponed_efuses):
672676
@staticmethod
673677
def confirm(action, do_not_confirm):
674678
log.print(
675-
"{}{}\nThis is an irreversible operation!".format(action, "" if action.endswith("\n") else ". ")
679+
"{}{}\nThis is an irreversible operation!".format(
680+
action, "" if action.endswith("\n") else ". "
681+
)
676682
)
677683
if not do_not_confirm:
678684
log.print("Type 'BURN' (all capitals) to continue.", flush=True)

espefuse/efuse/base_operations.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,9 @@ def read_protect_efuse(self, efuse_names: list[str]):
991991
]
992992
if error:
993993
raise esptool.FatalError(
994-
"{} must be readable, stop this operation!".format(efuse_name)
994+
"{} must be readable, stop this operation!".format(
995+
efuse_name
996+
)
995997
)
996998
else:
997999
for block in self.efuses.Blocks.BLOCKS:
@@ -1001,7 +1003,9 @@ def read_protect_efuse(self, efuse_names: list[str]):
10011003
self.efuses[block.key_purpose].get()
10021004
):
10031005
raise esptool.FatalError(
1004-
"{} must be readable, stop this operation!".format(efuse_name)
1006+
"{} must be readable, stop this operation!".format(
1007+
efuse_name
1008+
)
10051009
)
10061010
break
10071011
# make full list of which efuses will be disabled
@@ -1013,7 +1017,9 @@ def read_protect_efuse(self, efuse_names: list[str]):
10131017
]
10141018
names = ", ".join(e.name for e in all_disabling)
10151019
log.print(
1016-
"Permanently read-disabling eFuse{} {}".format("s" if len(all_disabling) > 1 else "", names)
1020+
"Permanently read-disabling eFuse{} {}".format(
1021+
"s" if len(all_disabling) > 1 else "", names
1022+
)
10171023
)
10181024
efuse.disable_read()
10191025

@@ -1054,7 +1060,9 @@ def write_protect_efuse(self, efuse_names: list[str]):
10541060
]
10551061
names = ", ".join(e.name for e in all_disabling)
10561062
log.print(
1057-
"Permanently write-disabling eFuse{} {}".format("s" if len(all_disabling) > 1 else "", names)
1063+
"Permanently write-disabling eFuse{} {}".format(
1064+
"s" if len(all_disabling) > 1 else "", names
1065+
)
10581066
)
10591067
efuse.disable_write()
10601068

@@ -1165,7 +1173,9 @@ def burn_bit(self, block: str, bit_number: list[int]):
11651173
data_block.reverse()
11661174
log.print(
11671175
"bit_number: "
1168-
"[{:03d}]........................................................[0]".format(data_block.len - 1)
1176+
"[{:03d}]........................................................[0]".format(
1177+
data_block.len - 1
1178+
)
11691179
)
11701180
log.print("BLOCK{:>2d} :".format(block_obj.id), data_block)
11711181
block_obj.print_block(data_block, "regs_to_write", debug=True)

espefuse/efuse/csv_table_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,4 @@ def __init__(self, e):
266266

267267
class ValidationError(InputError):
268268
def __init__(self, p, message):
269-
super().__init__(
270-
f"Entry {p.field_name} invalid: {message}"
271-
)
269+
super().__init__(f"Entry {p.field_name} invalid: {message}")

espefuse/efuse/esp32/fields.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def __init__(
8282
self.BLOCKS_FOR_KEYS = self.Blocks.get_blocks_for_keys()
8383
if esp.CHIP_NAME != "ESP32":
8484
raise esptool.FatalError(
85-
"Expected the 'esp' param for ESP32 chip but got for '{}'.".format(esp.CHIP_NAME)
85+
"Expected the 'esp' param for ESP32 chip but got for '{}'.".format(
86+
esp.CHIP_NAME
87+
)
8688
)
8789
self.blocks = [
8890
EfuseBlock(self, self.Blocks.get(block), skip_read=skip_connect)
@@ -114,7 +116,9 @@ def __init__(
114116
]
115117
else:
116118
raise esptool.FatalError(
117-
"The coding scheme ({}) - is not supported".format(self.coding_scheme)
119+
"The coding scheme ({}) - is not supported".format(
120+
self.coding_scheme
121+
)
118122
)
119123
if self["MAC_VERSION"].get() == 1:
120124
self.efuses += [

espefuse/efuse/esp32/operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ def burn_key_digest(
295295
if chip_revision < 300:
296296
raise esptool.FatalError(
297297
"Incorrect chip revision for Secure boot v2. "
298-
"Detected: v{}.{}. Expected: >= v3.0".format(chip_revision // 100, chip_revision % 100)
298+
"Detected: v{}.{}. Expected: >= v3.0".format(
299+
chip_revision // 100, chip_revision % 100
300+
)
299301
)
300302

301303
digest = espsecure._digest_sbv2_public_key(keyfile)

espefuse/efuse/esp32c2/fields.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def __init__(
7272
self.BLOCKS_FOR_KEYS = self.Blocks.get_blocks_for_keys()
7373
if esp.CHIP_NAME != "ESP32-C2":
7474
raise esptool.FatalError(
75-
"Expected the 'esp' param for ESP32-C2 chip but got for '{}'.".format(esp.CHIP_NAME)
75+
"Expected the 'esp' param for ESP32-C2 chip but got for '{}'.".format(
76+
esp.CHIP_NAME
77+
)
7678
)
7779
if not skip_connect:
7880
flags = self._esp.get_security_info()["flags"]
@@ -224,7 +226,9 @@ def set_efuse_timing(self):
224226
xtal_freq = self.get_crystal_freq()
225227
if xtal_freq not in [26, 40]:
226228
raise esptool.FatalError(
227-
"The eFuse supports only xtal=26M and 40M (xtal was {})".format(xtal_freq)
229+
"The eFuse supports only xtal=26M and 40M (xtal was {})".format(
230+
xtal_freq
231+
)
228232
)
229233

230234
self.update_reg(self.REGS.EFUSE_DAC_CONF_REG, self.REGS.EFUSE_DAC_NUM_M, 0xFF)

espefuse/efuse/esp32c2/operations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ def burn_key(
153153
):
154154
raise esptool.FatalError(
155155
"The number of blocks ({}), datafile ({}) and "
156-
"keypurpose ({}) should be the same.".format(len(block_name_list), len(datafile_list), len(keypurpose_list))
156+
"keypurpose ({}) should be the same.".format(
157+
len(block_name_list), len(datafile_list), len(keypurpose_list)
158+
)
157159
)
158160

159161
assert 1 <= len(block_name_list) <= 2, "Unexpected case"
@@ -277,7 +279,9 @@ def burn_key_digest(
277279
if len(digest) != num_bytes:
278280
raise esptool.FatalError(
279281
"Incorrect digest size {}. "
280-
"Digest must be {} bytes ({} bits) of raw binary key data.".format(len(digest), num_bytes, num_bytes * 8)
282+
"Digest must be {} bytes ({} bits) of raw binary key data.".format(
283+
len(digest), num_bytes, num_bytes * 8
284+
)
281285
)
282286
self.burn_key(
283287
["BLOCK_KEY0"],

espefuse/efuse/esp32c3/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def __init__(
7272
self.BLOCKS_FOR_KEYS = self.Blocks.get_blocks_for_keys()
7373
if esp.CHIP_NAME != "ESP32-C3":
7474
raise esptool.FatalError(
75-
"Expected the 'esp' param for ESP32-C3 chip but got for '{}'.".format(esp.CHIP_NAME)
75+
"Expected the 'esp' param for ESP32-C3 chip but got for '{}'.".format(
76+
esp.CHIP_NAME
77+
)
7678
)
7779
if not skip_connect:
7880
flags = self._esp.get_security_info()["flags"]

espefuse/efuse/esp32c3/operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ def burn_key_digest(
294294
if len(digest) != num_bytes:
295295
raise esptool.FatalError(
296296
"Incorrect digest size {}. Digest must be {} bytes ({} bits) "
297-
"of raw binary key data.".format(len(digest), num_bytes, num_bytes * 8)
297+
"of raw binary key data.".format(
298+
len(digest), num_bytes, num_bytes * 8
299+
)
298300
)
299301
digest_list.append(digest)
300302

espefuse/efuse/esp32c5/fields.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def __init__(
7272
self.BLOCKS_FOR_KEYS = self.Blocks.get_blocks_for_keys()
7373
if esp.CHIP_NAME != "ESP32-C5":
7474
raise esptool.FatalError(
75-
"Expected the 'esp' param for ESP32-C5 chip but got for '{}'.".format(esp.CHIP_NAME)
75+
"Expected the 'esp' param for ESP32-C5 chip but got for '{}'.".format(
76+
esp.CHIP_NAME
77+
)
7678
)
7779
if not skip_connect:
7880
flags = self._esp.get_security_info()["flags"]
@@ -232,7 +234,7 @@ def set_efuse_timing(self):
232234
apb_freq = self.get_crystal_freq()
233235
if apb_freq not in [40, 48]:
234236
raise esptool.FatalError(
235-
"The eFuse supports only xtal=40M and 48M (xtal was %d)" % apb_freq
237+
"The eFuse supports only xtal=40M and 48M (xtal was {}".format(apb_freq)
236238
)
237239

238240
self.update_reg(self.REGS.EFUSE_DAC_CONF_REG, self.REGS.EFUSE_DAC_NUM_M, 0xFF)
@@ -259,7 +261,7 @@ def get_coding_scheme_warnings(self, silent=False):
259261
]
260262
block.err_bitarray.pos = 0
261263
for word in reversed(words):
262-
block.err_bitarray.overwrite(BitArray("uint:32=%d" % word))
264+
block.err_bitarray.overwrite(BitArray("uint:32={}".format(word)))
263265
block.num_errors = block.err_bitarray.count(True)
264266
block.fail = block.num_errors != 0
265267
else:
@@ -276,8 +278,9 @@ def get_coding_scheme_warnings(self, silent=False):
276278
ret_fail |= block.fail
277279
if not silent and (block.fail or block.num_errors):
278280
log.print(
279-
"Error(s) in BLOCK%d [ERRORS:%d FAIL:%d]"
280-
% (block.id, block.num_errors, block.fail)
281+
"Error(s) in BLOCK{} [ERRORS:{} FAIL:{}]".format(
282+
block.id, block.num_errors, block.fail
283+
)
281284
)
282285
if (self.debug or ret_fail) and not silent:
283286
self.print_status_regs()

0 commit comments

Comments
 (0)