Skip to content

Commit eccbc64

Browse files
Copilotdobairoland
andcommitted
Fix line length issues in f-string conversions
Co-authored-by: dobairoland <[email protected]>
1 parent 81014f0 commit eccbc64

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

espefuse/efuse/base_fields.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ def get_block_len(self):
214214
elif coding_scheme == self.parent.REGS.CODING_SCHEME_RS:
215215
return self.len * 4
216216
else:
217-
raise esptool.FatalError(
218-
f"Coding scheme ({coding_scheme}) not supported"
219-
)
217+
raise esptool.FatalError(f"Coding scheme ({coding_scheme}) not supported")
220218

221219
def get_coding_scheme(self):
222220
if self.id == 0:
@@ -264,7 +262,8 @@ def print_block(self, bit_string, comment, debug=False):
264262
if self.parent.debug or debug:
265263
bit_string.pos = 0
266264
log.print(
267-
f"{self.name:<15s} ({' '.join(self.alias)[:16]:<16s}) [{self.id:>2d}] {comment}:",
265+
f"{self.name:<15s} ({' '.join(self.alias)[:16]:<16s}) "
266+
f"[{self.id:>2d}] {comment}:",
268267
" ".join(
269268
[
270269
f"{word:08x}"
@@ -284,7 +283,8 @@ def check_wr_data(self):
284283
return False
285284
if len(wr_data.bytes) != len(self.bitarray.bytes):
286285
raise esptool.FatalError(
287-
f"Data does not fit: block{self.id} size {len(self.bitarray.bytes)} bytes, data {len(wr_data.bytes)} bytes"
286+
f"Data does not fit: block{self.id} size "
287+
f"{len(self.bitarray.bytes)} bytes, data {len(wr_data.bytes)} bytes"
288288
)
289289
self.check_wr_rd_protect()
290290

@@ -671,9 +671,10 @@ def burn_block(block, postponed_efuses):
671671

672672
@staticmethod
673673
def confirm(action, do_not_confirm):
674-
newline = '\n'
674+
newline = "\n"
675675
log.print(
676-
f"{action}{'' if action.endswith(newline) else '. '}{newline}This is an irreversible operation!"
676+
f"{action}{'' if action.endswith(newline) else '. '}{newline}"
677+
f"This is an irreversible operation!"
677678
)
678679
if not do_not_confirm:
679680
log.print("Type 'BURN' (all capitals) to continue.", flush=True)

espefuse/efuse/base_operations.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,8 @@ def read_protect_efuse(self, efuse_names: list[str]):
10011001
self.efuses[block.key_purpose].get()
10021002
):
10031003
raise esptool.FatalError(
1004-
f"{efuse_name} must be readable, stop this operation!"
1004+
f"{efuse_name} must be readable, "
1005+
f"stop this operation!"
10051006
)
10061007
break
10071008
# make full list of which efuses will be disabled
@@ -1013,7 +1014,8 @@ def read_protect_efuse(self, efuse_names: list[str]):
10131014
]
10141015
names = ", ".join(e.name for e in all_disabling)
10151016
log.print(
1016-
f"Permanently read-disabling eFuse{'s' if len(all_disabling) > 1 else ''} {names}"
1017+
f"Permanently read-disabling eFuse"
1018+
f"{'s' if len(all_disabling) > 1 else ''} {names}"
10171019
)
10181020
efuse.disable_read()
10191021

@@ -1054,7 +1056,8 @@ def write_protect_efuse(self, efuse_names: list[str]):
10541056
]
10551057
names = ", ".join(e.name for e in all_disabling)
10561058
log.print(
1057-
f"Permanently write-disabling eFuse{'s' if len(all_disabling) > 1 else ''} {names}"
1059+
f"Permanently write-disabling eFuse"
1060+
f"{'s' if len(all_disabling) > 1 else ''} {names}"
10581061
)
10591062
efuse.disable_write()
10601063

@@ -1164,7 +1167,8 @@ def burn_bit(self, block: str, bit_number: list[int]):
11641167
)
11651168
data_block.reverse()
11661169
log.print(
1167-
f"bit_number: [{data_block.len - 1:03d}]........................................................[0]"
1170+
f"bit_number: [{data_block.len - 1:03d}]"
1171+
f"........................................................[0]"
11681172
)
11691173
log.print(f"BLOCK{block_obj.id:>2d} :", data_block)
11701174
block_obj.print_block(data_block, "regs_to_write", debug=True)

espefuse/efuse/esp32/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ def get_and_check(raw_mac, stored_crc):
298298
if computed_crc == stored_crc:
299299
valid_msg = f"(CRC 0x{stored_crc:02x} OK)"
300300
else:
301-
valid_msg = f"(CRC 0x{stored_crc:02x} invalid - calculated 0x{computed_crc:02x})"
301+
valid_msg = (
302+
f"(CRC 0x{stored_crc:02x} invalid - calculated 0x{computed_crc:02x})"
303+
)
302304
return f"{util.hexify(raw_mac, ':')} {valid_msg}"
303305

304306
@staticmethod

esptool/bin_image.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def load_segment(self, f, is_irom_segment=False):
265265
segment_data = f.read(size)
266266
if len(segment_data) < size:
267267
raise FatalError(
268-
f"End of file reading segment 0x{offset:x}, length {size} (actual {len(segment_data)})"
268+
f"End of file reading segment 0x{offset:x}, length {size} "
269+
f"(actual {len(segment_data)})"
269270
)
270271
segment = ImageSegment(offset, segment_data, file_offs)
271272
self.segments.append(segment)
@@ -297,7 +298,8 @@ def maybe_patch_segment_data(self, f, segment_data):
297298
):
298299
raise FatalError(
299300
f"Cannot place SHA256 digest on segment boundary"
300-
f"(elf_sha256_offset={self.elf_sha256_offset}, file_pos={file_pos}, segment_size={segment_len})"
301+
f"(elf_sha256_offset={self.elf_sha256_offset}, "
302+
f"file_pos={file_pos}, segment_size={segment_len})"
301303
)
302304
# offset relative to the data part
303305
patch_offset -= self.SEG_HEADER_LEN
@@ -306,7 +308,8 @@ def maybe_patch_segment_data(self, f, segment_data):
306308
!= b"\x00" * self.SHA256_DIGEST_LEN
307309
):
308310
raise FatalError(
309-
f"Contents of segment at SHA256 digest offset 0x{self.elf_sha256_offset:x} are not zero. "
311+
f"Contents of segment at SHA256 digest offset "
312+
f"0x{self.elf_sha256_offset:x} are not zero. "
310313
"Refusing to overwrite."
311314
)
312315
assert len(self.elf_sha256) == self.SHA256_DIGEST_LEN
@@ -403,7 +406,8 @@ def get_irom_segment(self):
403406
if len(irom_segments) > 0:
404407
if len(irom_segments) != 1:
405408
raise FatalError(
406-
f"Found {len(irom_segments)} segments that could be irom0. Bad ELF file?"
409+
f"Found {len(irom_segments)} segments that could be irom0. "
410+
f"Bad ELF file?"
407411
)
408412
return irom_segments[0]
409413
return None
@@ -441,7 +445,8 @@ def merge_adjacent_segments(self):
441445
and elem_pad_addr == next_elem.addr
442446
):
443447
log.note(
444-
f"Inserting {next_elem.addr - (elem.addr + len(elem.data))} bytes padding between {elem.name} and {next_elem.name}"
448+
f"Inserting {next_elem.addr - (elem.addr + len(elem.data))} "
449+
f"bytes padding between {elem.name} and {next_elem.name}"
445450
)
446451
elem.pad_until_addr(elem_pad_addr)
447452
if all(
@@ -634,7 +639,8 @@ def default_output_name(self, input_file):
634639
irom_offs = irom_segment.addr - ESP8266ROM.IROM_MAP_START
635640
else:
636641
irom_offs = 0
637-
return f"{os.path.splitext(input_file)[0]}-0x{irom_offs & ~(ESPLoader.FLASH_SECTOR_SIZE - 1):05x}.bin"
642+
sector_mask = ~(ESPLoader.FLASH_SECTOR_SIZE - 1)
643+
return f"{os.path.splitext(input_file)[0]}-0x{irom_offs & sector_mask:05x}.bin"
638644

639645
def save(self, filename: str | None) -> bytes | None:
640646
with io.BytesIO() as f: # Write to memory first

esptool/loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,10 @@ def __str__(self):
19761976
for c in line.decode("ascii", "replace")
19771977
)
19781978
s = s[16:]
1979-
result += f"\n {hexify(line[:8], False):<16s} {hexify(line[8:], False):<16s} | {ascii_line}"
1979+
result += (
1980+
f"\n {hexify(line[:8], False):<16s} "
1981+
f"{hexify(line[8:], False):<16s} | {ascii_line}"
1982+
)
19801983
return result
19811984
else:
19821985
return hexify(self._s, False)

0 commit comments

Comments
 (0)