From 7e93f286d76d58d371bb80d3756ee35d438116b1 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:05:08 +0000 Subject: [PATCH] refactor: use `sys.exit()` calls The `exit` or `quit` functions don't exist at top-level if python is started with the `-S` flag, and will raise an error. Use `sys.exit()` instead. --- src/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index 94e28cf2..ba378a90 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ import argparse import os import random +import sys from train import train, run @@ -20,7 +21,7 @@ def check_map(map_name): if map_name not in get_available_maps(): print(f"Map '{map_name}' not found. Available maps:") print(get_available_maps()) - exit(1) + sys.exit(1) if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -51,7 +52,7 @@ def check_map(map_name): if args.list: print("Available maps:") print(get_available_maps()) - exit(0) + sys.exit(0) elif args.command == 'train': print("Training the model") if 'random' not in args.map: @@ -65,14 +66,14 @@ def check_map(map_name): args.max_learning_rate, args.num_of_steps, args.optimize_speed) - exit(0) + sys.exit(0) elif args.command == 'run': print("Running the model") if args.map == 'random': args.map = random.choice(available_maps) check_map(args.map) run(args.map, args.timesteps) - exit(0) + sys.exit(0) else: print("Invalid command") - exit(1) \ No newline at end of file + sys.exit(1) \ No newline at end of file