Skip to content

Commit 478d9ec

Browse files
committed
Minor formatting updates for ruff v0.9.
Mainly addition of whitespace within expressions in f-strings.
1 parent cf18cdd commit 478d9ec

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/mp_image_tool_esp32/argtypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class IntArg(int):
3737
kilobytes).
3838
"""
3939

40+
# 'int' is immutable, so we need to override __new__() instead of __init__().
4041
def __new__(cls, arg: str) -> IntArg:
4142
if not arg:
4243
arg = "0"
43-
unit = 1
44+
unit: int = 1
4445
for k, v in SIZE_UNITS.items():
4546
if arg.upper().endswith(k.upper()):
4647
arg, unit = arg[: -len(k)], v

src/mp_image_tool_esp32/esptool_io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def __init__(self, port: str, baud: int = 0):
131131
self.flash_size = int(match.group(1)) * MB if match else 0
132132
if self.chip_name:
133133
self.esptool_args = " ".join((self.esptool_args, "--chip", self.chip_name))
134-
log.debug(f"Detected {self.chip_name} with flash size {self.flash_size/MB}MB.")
134+
log.debug(
135+
f"Detected {self.chip_name} with flash size {self.flash_size / MB}MB."
136+
)
135137

136138
def esptool_run(self, cmd: str) -> None:
137139
"""Run an esptool command in a subprocess and echo output to sys.stdout."""

src/mp_image_tool_esp32/firmware_fileio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def __init__(
129129
and self.esptool.flash_size != self.header.flash_size
130130
):
131131
log.warning(
132-
f"Detected flash size ({self.esptool.flash_size//MB}MB) is "
132+
f"Detected flash size ({self.esptool.flash_size // MB}MB) is "
133133
f"different from firmware bootloader "
134-
f"({self.header.flash_size//MB}MB).\n"
134+
f"({self.header.flash_size // MB}MB).\n"
135135
" [italic]Use the '-f' option to change the size in the bootloader."
136136
)
137137

src/mp_image_tool_esp32/lfs.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def hits(self) -> int:
5555

5656
def summary(self) -> str:
5757
return (
58-
f"cache hits: {self.hits} cache misses: "
59-
f"{self.misses} writes: {self.writes}"
58+
f"cache hits: {self.hits} cache misses: {self.misses} writes: {self.writes}"
6059
)
6160

6261

@@ -176,9 +175,9 @@ def write_block(self, block: int, data: bytes) -> None:
176175
def read(self, cfg: LFSConfig, block: int, off: int, size: int) -> bytearray:
177176
log.debug("LFS Read : Block: %d, Offset: %d, Size=%d" % (block, off, size))
178177
assert off == 0, "Read offset must be 0"
179-
assert (
180-
size == cfg.block_size == self.block_cache.block_size
181-
), "Read size must be block size"
178+
assert size == cfg.block_size == self.block_cache.block_size, (
179+
"Read size must be block size"
180+
)
182181
start, end = block, block + (off + size) // cfg.block_size
183182
data = b"".join(self.read_block(i) for i in range(start, end + 1))
184183
return bytearray(data[off : off + size])
@@ -187,9 +186,9 @@ def prog(self, cfg: "LFSConfig", block: int, off: int, data: bytes) -> int:
187186
log.debug("LFS Prog : Block: %d, Offset: %d, Size=%d" % (block, off, len(data)))
188187
block_size = cfg.block_size
189188
assert off == 0, "Write offset must be 0"
190-
assert (
191-
len(data) == block_size == self.block_cache.block_size
192-
), "Write size must be block size"
189+
assert len(data) == block_size == self.block_cache.block_size, (
190+
"Write size must be block size"
191+
)
193192
for i in range(len(data) // block_size):
194193
self.write_block(
195194
block + i,
@@ -329,7 +328,7 @@ def do_info(self) -> None:
329328
print(f" Block Size: {fs.cfg.block_size:9d} / 0x{fs.cfg.block_size:X}")
330329
print(f" Blocks Total:{fs.block_count:9d}")
331330
print(f" Blocks Used: {fs.used_block_count:>9d}")
332-
print(f" Blocks Free: {fs.block_count-fs.used_block_count:>9d}")
331+
print(f" Blocks Free: {fs.block_count - fs.used_block_count:>9d}")
333332

334333
def do_df(self) -> None:
335334
"""Print size and usage information about the LittleFS filesystem."""

0 commit comments

Comments
 (0)