[GH-ISSUE #54] --list-rounds and --list-sprints flags don't exit after execution #12

Closed
opened 2026-05-07 00:17:34 +02:00 by BreizhHardware · 6 comments

Originally created by @Mithurn on GitHub (Dec 16, 2025).
Original GitHub issue: https://github.com/IAmTomShaw/f1-race-replay/issues/54

When using the --list-rounds or --list-sprints flags, the program correctly lists the rounds but then continues to execute the main() function, causing errors or unexpected behavior.

Expected Behavior:
The program should display the list of rounds and exit cleanly.

Actual Behavior:
The program lists the rounds, then attempts to load session data for the default round, which is unnecessary and may cause errors.

Suggested Fix
Add [sys.exit(0)]
after the list functions:

if "--list-rounds" in sys.argv:
list_rounds(year)
sys.exit(0)
elif "--list-sprints" in sys.argv:
list_sprints(year)
sys.exit(0)

Originally created by @Mithurn on GitHub (Dec 16, 2025). Original GitHub issue: https://github.com/IAmTomShaw/f1-race-replay/issues/54 When using the `--list-rounds` or `--list-sprints` flags, the program correctly lists the rounds but then continues to execute the `main()` function, causing errors or unexpected behavior. Expected Behavior: The program should display the list of rounds and exit cleanly. Actual Behavior: The program lists the rounds, then attempts to load session data for the default round, which is unnecessary and may cause errors. Suggested Fix Add [sys.exit(0)] after the list functions: if "--list-rounds" in sys.argv: list_rounds(year) sys.exit(0) elif "--list-sprints" in sys.argv: list_sprints(year) sys.exit(0)
Author
Owner

@IAmTomShaw commented on GitHub (Dec 16, 2025):

That's odd. They exit on my main branch

<!-- gh-comment-id:3662404514 --> @IAmTomShaw commented on GitHub (Dec 16, 2025): That's odd. They exit on my main branch
Author
Owner

@IAmTomShaw commented on GitHub (Dec 16, 2025):

Lines 845 and 863 exit the application. I suppose we could move the exits to the main.py file to make things look neater

<!-- gh-comment-id:3662408144 --> @IAmTomShaw commented on GitHub (Dec 16, 2025): Lines 845 and 863 exit the application. I suppose we could move the exits to the main.py file to make things look neater
Author
Owner

@Keshav02-rk commented on GitHub (Dec 16, 2025):

Thanks for the clarification! I agree that moving the sys.exit(0) calls into main.py would make the behavior more explicit and easier to follow. This would also help prevent confusion for contributors using the --list-rounds and --list-sprints flags. I can help implement this if needed and open a PR for the change.

<!-- gh-comment-id:3662416035 --> @Keshav02-rk commented on GitHub (Dec 16, 2025): Thanks for the clarification! I agree that moving the `sys.exit(0)` calls into `main.py` would make the behavior more explicit and easier to follow. This would also help prevent confusion for contributors using the `--list-rounds` and `--list-sprints` flags. I can help implement this if needed and open a PR for the change.
Author
Owner

@Mithurn commented on GitHub (Dec 17, 2025):

Thanks for the clarification! I've opened PR #55 which implements your suggestion to move the [sys.exit(0)] calls into main.py. This makes the exit behavior more explicit and easier to follow.

Currently, the code has [sys.exit()] calls in both locations:

Lines 845 and 863 in [f1_data.py] (within the [list_rounds] and [list_sprints] functions)
Lines 84 and 87 in [main.py] (after calling these functions)

Should I also remove the [sys.exit()] calls from [f1_data.py] to avoid the redundancy?

<!-- gh-comment-id:3663773611 --> @Mithurn commented on GitHub (Dec 17, 2025): Thanks for the clarification! I've opened PR #55 which implements your suggestion to move the [sys.exit(0)] calls into main.py. This makes the exit behavior more explicit and easier to follow. Currently, the code has [sys.exit()] calls in both locations: Lines 845 and 863 in [f1_data.py] (within the [list_rounds] and [list_sprints] functions) Lines 84 and 87 in [main.py] (after calling these functions) Should I also remove the [sys.exit()] calls from [f1_data.py] to avoid the redundancy?
Author
Owner

@Keshav02-rk commented on GitHub (Dec 17, 2025):

I’d suggest removing the sys.exit() calls from f1_data.py and keeping the exit logic only in main.py. That keeps helper functions side-effect free and makes the flow easier to follow.

<!-- gh-comment-id:3664909794 --> @Keshav02-rk commented on GitHub (Dec 17, 2025): I’d suggest removing the sys.exit() calls from f1_data.py and keeping the exit logic only in main.py. That keeps helper functions side-effect free and makes the flow easier to follow.
Author
Owner

@IAmTomShaw commented on GitHub (Dec 18, 2025):

This issue has been resolved now :)

<!-- gh-comment-id:3667640564 --> @IAmTomShaw commented on GitHub (Dec 18, 2025): This issue has been resolved now :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#12
No description provided.