You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add_mutually_exclusive_group is buggy when options are given default values
Behaviour is difficult to describe, but it seems like default options aren't correctly added if left at their default value. Try to run this code and you'll see what I mean.
I would have expected the code to work with args.first ==1 when first is selected, and likewise for args.second. As it is, this just crashes and says neither are selected.
Minimal reproducer:
@Gooey(program_name="Minimal Reproducer")
def main():
parser = GooeyParser()
mutex = parser.add_mutually_exclusive_group(
required=True, gooey_options={"initial_selection": 0}
)
mutex.add_argument(
"--first",
type=int,
default=1,
help="First mutex argument."
)
mutex.add_argument(
"--second",
type=int,
default=2,
help=f"Second mutex argument.",
)
args = parser.parse_args()
if hasattr(args, "first") and args.first is not None:
print(f"first: {args.first}")
elif hasattr(args, "second") and args.second is not None:
print(f"second: {args.second}")
if __name__ == "__main__":
main()
For my own usage I'm able to just enforce the behaviour I want by writing a little code, but this did not work the way I would have expected.
The text was updated successfully, but these errors were encountered:
add_mutually_exclusive_group
is buggy when options are given default valuesargs.first ==1
whenfirst
is selected, and likewise forargs.second
. As it is, this just crashes and says neither are selected.Minimal reproducer:
For my own usage I'm able to just enforce the behaviour I want by writing a little code, but this did not work the way I would have expected.
The text was updated successfully, but these errors were encountered: