Skip to content

Commit c3be9a4

Browse files
committed
Using match-case instead of if-else. Also fixed a bug
1 parent b5964fd commit c3be9a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/llmcompressor/metrics/logger.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,13 @@ def _log_lambda(
389389
def is_higher_than_debug(lev: int | str | None = None) -> bool:
390390
"""Check if the given level is higher than DEBUG level."""
391391
debug_level_no = logger.level("DEBUG").no
392-
if isinstance(lev, int):
393-
return level > debug_level_no
394-
elif isinstance(lev, str):
395-
return logger.level(lev).no > debug_level_no
396-
return False
392+
match lev:
393+
case int():
394+
return lev > debug_level_no
395+
case str():
396+
return logger.level(lev).no > debug_level_no
397+
case _:
398+
return False
397399

398400
if is_higher_than_debug(level):
399401
if step is not None:

0 commit comments

Comments
 (0)