Skip to content

Commit d43b6c7

Browse files
Use lazy % formatting in logging functions (#2366)
* Use lazy % formatting in logging functions * f-string should be more efficient * Space before unit symbol From "SI Unit rules and style conventions": https://physics.nist.gov/cuu/Units/checklist.html There is a space between the numerical value and unit symbol, even when the value is used in an adjectival sense, except in the case of superscript units for plane angle. * Enforce ruff/flake8-logging-format rules (G) --------- Co-authored-by: Joe Hamman <joe@earthmover.io>
1 parent fe752a2 commit d43b6c7

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ extend-select = [
211211
"B", # flake8-bugbear
212212
"C4", # flake8-comprehensions
213213
"FLY", # flynt
214+
"G", # flake8-logging-format
214215
"I", # isort
215216
"ISC", # flake8-implicit-str-concat
216217
"PGH", # pygrep-hooks

src/zarr/core/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def sync(
133133

134134
finished, unfinished = wait([future], return_when=asyncio.ALL_COMPLETED, timeout=timeout)
135135
if len(unfinished) > 0:
136-
raise TimeoutError(f"Coroutine {coro} failed to finish in within {timeout}s")
136+
raise TimeoutError(f"Coroutine {coro} failed to finish in within {timeout} s")
137137
assert len(finished) == 1
138138
return_result = next(iter(finished)).result()
139139

src/zarr/storage/logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ def log(self, hint: Any = "") -> Generator[None, None, None]:
8383
method = inspect.stack()[2].function
8484
op = f"{type(self._store).__name__}.{method}"
8585
if hint:
86-
op += f"({hint})"
87-
self.logger.info(f"Calling {op}")
86+
op = f"{op}({hint})"
87+
self.logger.info("Calling %s", op)
8888
start_time = time.time()
8989
try:
9090
self.counter[method] += 1
9191
yield
9292
finally:
9393
end_time = time.time()
94-
self.logger.info(f"Finished {op} [{end_time - start_time:.2f}s]")
94+
self.logger.info("Finished %s [%.2f s]", op, end_time - start_time)
9595

9696
@property
9797
def supports_writes(self) -> bool:

0 commit comments

Comments
 (0)