Skip to content

Commit feef7d3

Browse files
committed
pre-commit fix
1 parent 0db41e3 commit feef7d3

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.11.0"
3+
rev: v0.11.13
44
hooks:
5-
- id: ruff
5+
- id: ruff-check
66
args: [--fix, --exit-non-zero-on-fix, --config=pyproject.toml]
77
- id: ruff-format

codeflash/cli_cmds/cmd_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from argparse import Namespace
3535

3636
CODEFLASH_LOGO: str = (
37-
f"{LF}" # noqa: ISC003
37+
f"{LF}"
3838
r" _ ___ _ _ " + f"{LF}"
3939
r" | | / __)| | | | " + f"{LF}"
4040
r" ____ ___ _ | | ____ | |__ | | ____ ___ | | _ " + f"{LF}"

codeflash/code_utils/time_utils.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,43 @@ def humanize_runtime(time_in_ns: int) -> str:
5252

5353

5454
def format_time(nanoseconds: int) -> str:
55-
"""Format nanoseconds into a human-readable string with 3 significant digits when needed."""
56-
# Inlined significant digit check: >= 3 digits if value >= 100
55+
result = ""
5756
if nanoseconds < 1_000:
58-
return f"{nanoseconds}ns"
59-
if nanoseconds < 1_000_000:
57+
result = f"{nanoseconds}ns"
58+
elif nanoseconds < 1_000_000:
6059
microseconds_int = nanoseconds // 1_000
6160
if microseconds_int >= 100:
62-
return f"{microseconds_int}μs"
63-
microseconds = nanoseconds / 1_000
64-
# Format with precision: 3 significant digits
65-
if microseconds >= 100:
66-
return f"{microseconds:.0f}μs"
67-
if microseconds >= 10:
68-
return f"{microseconds:.1f}μs"
69-
return f"{microseconds:.2f}μs"
70-
if nanoseconds < 1_000_000_000:
61+
result = f"{microseconds_int}μs"
62+
else:
63+
microseconds = nanoseconds / 1_000
64+
if microseconds >= 100:
65+
result = f"{microseconds:.0f}μs"
66+
elif microseconds >= 10:
67+
result = f"{microseconds:.1f}μs"
68+
else:
69+
result = f"{microseconds:.2f}μs"
70+
elif nanoseconds < 1_000_000_000:
7171
milliseconds_int = nanoseconds // 1_000_000
7272
if milliseconds_int >= 100:
73-
return f"{milliseconds_int}ms"
74-
milliseconds = nanoseconds / 1_000_000
75-
if milliseconds >= 100:
76-
return f"{milliseconds:.0f}ms"
77-
if milliseconds >= 10:
78-
return f"{milliseconds:.1f}ms"
79-
return f"{milliseconds:.2f}ms"
80-
seconds_int = nanoseconds // 1_000_000_000
81-
if seconds_int >= 100:
82-
return f"{seconds_int}s"
83-
seconds = nanoseconds / 1_000_000_000
84-
if seconds >= 100:
85-
return f"{seconds:.0f}s"
86-
if seconds >= 10:
87-
return f"{seconds:.1f}s"
88-
return f"{seconds:.2f}s"
73+
result = f"{milliseconds_int}ms"
74+
else:
75+
milliseconds = nanoseconds / 1_000_000
76+
if milliseconds >= 100:
77+
result = f"{milliseconds:.0f}ms"
78+
elif milliseconds >= 10:
79+
result = f"{milliseconds:.1f}ms"
80+
else:
81+
result = f"{milliseconds:.2f}ms"
82+
else:
83+
seconds_int = nanoseconds // 1_000_000_000
84+
if seconds_int >= 100:
85+
result = f"{seconds_int}s"
86+
else:
87+
seconds = nanoseconds / 1_000_000_000
88+
if seconds >= 100:
89+
result = f"{seconds:.0f}s"
90+
elif seconds >= 10:
91+
result = f"{seconds:.1f}s"
92+
else:
93+
result = f"{seconds:.2f}s"
94+
return result

codeflash/discovery/discover_unit_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ def process_test_files(
473473
else:
474474
uncached_files[test_file] = functions
475475

476-
# Process cached files first
477476
for test_file, (_functions, cached_tests, file_hash) in cached_files.items():
478477
cur = tests_cache.cur
479478
cur.execute(
@@ -522,7 +521,7 @@ def process_test_files(
522521
for qualified_name, function_called in results:
523522
function_to_test_map[qualified_name].add(function_called)
524523
progress.advance(task_id)
525-
except Exception as e: # noqa: PERF203
524+
except Exception as e:
526525
test_file = future_to_file[future]
527526
logger.error(f"Error processing test file {test_file}: {e}")
528527
progress.advance(task_id)

0 commit comments

Comments
 (0)