Skip to content

Commit de8f0c4

Browse files
committed
refactor: transform asserts into condition
1 parent 76695ed commit de8f0c4

File tree

1 file changed

+7
-2
lines changed
  • src/depinfo/infrastructure/application

1 file changed

+7
-2
lines changed

src/depinfo/infrastructure/application/cli.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818

1919
import argparse
2020
import logging
21+
import sys
2122
from typing import List, Optional
2223

2324
from depinfo.domain import DependencyReport
2425

2526
from .display_service_registry import DisplayServiceRegistry, DisplayType
2627

2728

29+
logger = logging.getLogger()
30+
31+
2832
MAX_DEPTH = 5
2933

3034

@@ -75,8 +79,9 @@ def main(argv: Optional[List[str]] = None) -> None:
7579
"""Coordinate argument parsing, input validation, and program execution."""
7680
args = parse_arguments(argv)
7781
logging.basicConfig(level=args.log_level, format="[%(levelname)s] %(message)s")
78-
assert args.max_depth >= 0, "The maximum depth must be >=0."
79-
assert args.max_depth < MAX_DEPTH, "Don't exaggerate!"
82+
if not (0 <= args.max_depth < MAX_DEPTH):
83+
logger.critical(f"The maximum depth must be >=0 and <{MAX_DEPTH}.")
84+
sys.exit(2)
8085
report = DependencyReport.from_root(
8186
args.package_name,
8287
[token.strip() for token in args.build_tools.split(",")],

0 commit comments

Comments
 (0)