Skip to content

Commit

Permalink
refactor: use sys.exit() calls
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deepsource-autofix[bot] authored Jan 26, 2024
1 parent f7a4cb4 commit 7e93f28
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import os
import random
import sys

from train import train, run

Expand All @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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)
sys.exit(1)

0 comments on commit 7e93f28

Please sign in to comment.