[BUGFIX] in scripts/replay_implementation.py #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug
When you use type=bool with argparse, it doesn't work as expected because any non-empty string (including "False") evaluates to True in Python.
Thus,
from reply.py and reply_directory.py will always be true.
Solution
Added a str2bool function that properly converts string arguments to boolean values. This function handles various boolean representations like "true", "false", "yes", "no", "1", "0", etc.
Updated all boolean arguments to use type=str2bool instead of type=bool.
Now the script will correctly handle boolean arguments:
--rgb_enabled False will properly set the value to False
--rgb_enabled true will set it to True
--rgb_enabled 0 will set it to False
--rgb_enabled 1 will set it to True
The function also handles edge cases and provides a clear error message if an invalid boolean value is provided. This ensures that your boolean flags work as expected when called from the command line.